<!DOCTYPE html>
<html lang="en-US">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>中俊为 | we harmonyos</title>
    <meta name="generator" content="VuePress 1.9.7">
    <script>
          var _hmt = _hmt || [];
          (function() {
            var hm = document.createElement("script");
            hm.src = "https://hm.baidu.com/hm.js?39485dba914ae63b24732b6a90688f0b";
            var s = document.getElementsByTagName("script")[0];
            s.parentNode.insertBefore(hm, s);
          })();
      </script>
    <link rel="manifest" href="/manifest.webmanifest" crossorigin="use-credentials">
    <meta name="description" content="weharmonyos 鸿蒙论坛 鸿蒙注释 开源鸿蒙 鸿蒙源码 openharmony源码 HarmonyOS源码 HarmonyOS HarmonyOS生态 openharmony开发者文档 鸿蒙生态 鸿蒙系统 华为操作系统 鸿蒙研究站 开放原子开源基金会 百万汉字注解鸿蒙 百篇博客分析鸿蒙">
    <meta property="og:url" content="/blog/88.html">
    <meta property="og:site_name" content="中俊为 | we harmonyos">
    <meta property="og:description" content="本篇关键词：、、、 下载 &gt;&gt; 离线文档.鸿蒙内核源码分析(百篇博客分析.挖透鸿蒙内核).pdf.zip) 编译运行相关篇为: v84.02 鸿蒙内核源码分析(编译过程) | 简单案例说透中间过程; v85.03 鸿蒙内核源码分析(编译构建) | 编译鸿蒙防掉坑指南; v86.04 鸿蒙内核源码分析(GN语法) | 如何构建鸿蒙系统; v87.03 ">
    <meta property="og:type" content="article">
    <meta property="og:locale" content="en-US">
    <meta name="twitter:card" content="summary_large_image">
    <meta name="twitter:image:alt" content="中俊为 | we harmonyos">
    <meta name="theme-color" content="#46bd87">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover">
    
    <link rel="preload" href="/assets/css/0.styles.087eb7d3.css" as="style"><link rel="preload" href="/assets/js/app.9a8b95d8.js" as="script"><link rel="preload" href="/assets/js/vendors~layout-Layout.c1e797d4.js" as="script"><link rel="preload" href="/assets/js/vendors~layout-Blog~layout-Layout~layout-NotFound.f75cf258.js" as="script"><link rel="preload" href="/assets/js/page--70e38af0.eb8ffc53.js" as="script"><link rel="prefetch" href="/assets/js/160.a8046d43.js"><link rel="prefetch" href="/assets/js/161.29f8564f.js"><link rel="prefetch" href="/assets/js/162.249ee491.js"><link rel="prefetch" href="/assets/js/163.c57d1577.js"><link rel="prefetch" href="/assets/js/164.7a788aaa.js"><link rel="prefetch" href="/assets/js/165.c333afb2.js"><link rel="prefetch" href="/assets/js/166.9bcb7cd6.js"><link rel="prefetch" href="/assets/js/layout-Blog.4a9781d1.js"><link rel="prefetch" href="/assets/js/layout-Layout.7e277e0b.js"><link rel="prefetch" href="/assets/js/layout-NotFound.9326b14e.js"><link rel="prefetch" href="/assets/js/layout-Slide.8dd861e4.js"><link rel="prefetch" href="/assets/js/page--00854288.e2bc8e8a.js"><link rel="prefetch" href="/assets/js/page--00f8db0a.b2a35fe6.js"><link rel="prefetch" href="/assets/js/page--03ad6df0.d48f4c19.js"><link rel="prefetch" href="/assets/js/page--04b12ba8.e8add78d.js"><link rel="prefetch" href="/assets/js/page--070d2528.d24cd503.js"><link rel="prefetch" href="/assets/js/page--086560f0.a6be2844.js"><link rel="prefetch" href="/assets/js/page--090ad32d.fc7da3c3.js"><link rel="prefetch" href="/assets/js/page--0c054030.2886024e.js"><link rel="prefetch" href="/assets/js/page--0d9507c8.a27dee03.js"><link rel="prefetch" href="/assets/js/page--10bd3330.b5165172.js"><link rel="prefetch" href="/assets/js/page--1233b0b2.b5caca9c.js"><link rel="prefetch" href="/assets/js/page--13650e88.61330a2b.js"><link rel="prefetch" href="/assets/js/page--14c850b1.d9a40c31.js"><link rel="prefetch" href="/assets/js/page--15752630.25f9c756.js"><link rel="prefetch" href="/assets/js/page--19150570.58df8995.js"><link rel="prefetch" href="/assets/js/page--19ecf128.130d012b.js"><link rel="prefetch" href="/assets/js/page--1c48eaa8.9a689e30.js"><link rel="prefetch" href="/assets/js/page--1d4dfe96.bd551921.js"><link rel="prefetch" href="/assets/js/page--1dccf870.03d7d9cc.js"><link rel="prefetch" href="/assets/js/page--2074d3c8.06bf5706.js"><link rel="prefetch" href="/assets/js/page--22213c96.e703257a.js"><link rel="prefetch" href="/assets/js/page--2284eb70.514124de.js"><link rel="prefetch" href="/assets/js/page--22d0cd48.11ea1522.js"><link rel="prefetch" href="/assets/js/page--252cc6c8.f9acae83.js"><link rel="prefetch" href="/assets/js/page--2624cab0.4535fea2.js"><link rel="prefetch" href="/assets/js/page--269ff8f9.012e8ae6.js"><link rel="prefetch" href="/assets/js/page--26fcb668.35b2da5d.js"><link rel="prefetch" href="/assets/js/page--2958afe8.216913bc.js"><link rel="prefetch" href="/assets/js/page--2adcbdb0.6dcb4c27.js"><link rel="prefetch" href="/assets/js/page--2bb4a968.aac31797.js"><link rel="prefetch" href="/assets/js/page--2d849908.7bb4e817.js"><link rel="prefetch" href="/assets/js/page--2e10a2e8.42bef48d.js"><link rel="prefetch" href="/assets/js/page--2f94b0b0.0c993df5.js"><link rel="prefetch" href="/assets/js/page--2fe09288.77769dcb.js"><link rel="prefetch" href="/assets/js/page--323c8c08.254a5f78.js"><link rel="prefetch" href="/assets/js/page--33348ff0.a5f99eb0.js"><link rel="prefetch" href="/assets/js/page--340c7ba8.2c9570cb.js"><link rel="prefetch" href="/assets/js/page--34988588.8c8d0363.js"><link rel="prefetch" href="/assets/js/page--36687528.67d84e0d.js"><link rel="prefetch" href="/assets/js/page--37d6dfd6.88e9cd42.js"><link rel="prefetch" href="/assets/js/page--37ec82f0.5419c82d.js"><link rel="prefetch" href="/assets/js/page--37f7cf15.65f72e55.js"><link rel="prefetch" href="/assets/js/page--38c46ea8.5d5150f9.js"><link rel="prefetch" href="/assets/js/page--3a945e48.bf9758fb.js"><link rel="prefetch" href="/assets/js/page--3ab2204c.e08d6316.js"><link rel="prefetch" href="/assets/js/page--3b206828.d83e3926.js"><link rel="prefetch" href="/assets/js/page--3ca475f0.49e5acce.js"><link rel="prefetch" href="/assets/js/page--3cf057c8.8364331d.js"><link rel="prefetch" href="/assets/js/page--3f4c5148.587a8360.js"><link rel="prefetch" href="/assets/js/page--40445530.486bb516.js"><link rel="prefetch" href="/assets/js/page--411c40e8.2eedba0e.js"><link rel="prefetch" href="/assets/js/page--41a84ac8.f4a360a3.js"><link rel="prefetch" href="/assets/js/page--4220f8b5.19b4371f.js"><link rel="prefetch" href="/assets/js/page--43783a68.4faf0866.js"><link rel="prefetch" href="/assets/js/page--44fc4830.a160662c.js"><link rel="prefetch" href="/assets/js/page--45d433e8.560fef87.js"><link rel="prefetch" href="/assets/js/page--47a42388.052314b4.js"><link rel="prefetch" href="/assets/js/page--47d07816.66731286.js"><link rel="prefetch" href="/assets/js/page--48302d68.8d6493cf.js"><link rel="prefetch" href="/assets/js/page--49b43b30.e3684736.js"><link rel="prefetch" href="/assets/js/page--4a001d08.47f7ec45.js"><link rel="prefetch" href="/assets/js/page--4c5c1688.b7ec1f32.js"><link rel="prefetch" href="/assets/js/page--4d541a70.ee807705.js"><link rel="prefetch" href="/assets/js/page--4e2c0628.4f7105a4.js"><link rel="prefetch" href="/assets/js/page--4eb81008.725d26fe.js"><link rel="prefetch" href="/assets/js/page--5087ffa8.dac2aae0.js"><link rel="prefetch" href="/assets/js/page--520c0d70.2beedefb.js"><link rel="prefetch" href="/assets/js/page--52e3f928.2645087c.js"><link rel="prefetch" href="/assets/js/page--53cd0b44.96d4a285.js"><link rel="prefetch" href="/assets/js/page--54eb2c5e.27eb702b.js"><link rel="prefetch" href="/assets/js/page--553ff2a8.fba8ee4f.js"><link rel="prefetch" href="/assets/js/page--5686ab01.547b633c.js"><link rel="prefetch" href="/assets/js/page--56c40070.4e35708a.js"><link rel="prefetch" href="/assets/js/page--570fe248.2b301b36.js"><link rel="prefetch" href="/assets/js/page--596bdbc8.c74cd724.js"><link rel="prefetch" href="/assets/js/page--5a63dfb0.bbd49a9b.js"><link rel="prefetch" href="/assets/js/page--5bc7d548.eda26865.js"><link rel="prefetch" href="/assets/js/page--5f1bd2b0.e02cf88d.js"><link rel="prefetch" href="/assets/js/page--5ff3be68.b2b0e76e.js"><link rel="prefetch" href="/assets/js/page--624fb7e8.666fdc84.js"><link rel="prefetch" href="/assets/js/page--63d3c5b0.b587d38f.js"><link rel="prefetch" href="/assets/js/page--68d79a88.86f62e4d.js"><link rel="prefetch" href="/assets/js/page--6c2b97f0.ed46abea.js"><link rel="prefetch" href="/assets/js/page--6cc6a596.b3827451.js"><link rel="prefetch" href="/assets/js/page--6ea7a148.61a9bc10.js"><link rel="prefetch" href="/assets/js/page--7180d470.73a3a20e.js"><link rel="prefetch" href="/assets/js/page--752f83e8.d5c31640.js"><link rel="prefetch" href="/assets/js/page--778b7d68.5e8e5ea9.js"><link rel="prefetch" href="/assets/js/page--7bb76688.53e305e3.js"><link rel="prefetch" href="/assets/js/page--7c59a86a.ecf88c30.js"><link rel="prefetch" href="/assets/js/page--7df35030.cfa388f4.js"><link rel="prefetch" href="/assets/js/page--7e136008.230e9a15.js"><link rel="prefetch" href="/assets/js/page--89935db0.f79f9e25.js"><link rel="prefetch" href="/assets/js/page--96a322f0.412d537f.js"><link rel="prefetch" href="/assets/js/page--9b5b15f0.a5231547.js"><link rel="prefetch" href="/assets/js/page--a3b2e830.f4ba68fa.js"><link rel="prefetch" href="/assets/js/page--a86adb30.ec08486b.js"><link rel="prefetch" href="/assets/js/page--ad22ce30.4872eca4.js"><link rel="prefetch" href="/assets/js/page--b0c2ad70.8637057e.js"><link rel="prefetch" href="/assets/js/page--b57aa070.43215f9e.js"><link rel="prefetch" href="/assets/js/page--ba329370.b5f22d13.js"><link rel="prefetch" href="/assets/js/page--bdd272b0.aff1d1a9.js"><link rel="prefetch" href="/assets/js/page--c28a65b0.978514c4.js"><link rel="prefetch" href="/assets/js/page--c606edca.49d3396e.js"><link rel="prefetch" href="/assets/js/page--c74258b0.f85195bc.js"><link rel="prefetch" href="/assets/js/page--cae237f0.8a976cc1.js"><link rel="prefetch" href="/assets/js/page--cf9a2af0.7ad20ea2.js"><link rel="prefetch" href="/assets/js/page--d4521df0.a0a74934.js"><link rel="prefetch" href="/assets/js/page--d7f1fd30.160f138a.js"><link rel="prefetch" href="/assets/js/page--dca9f030.9127ab28.js"><link rel="prefetch" href="/assets/js/page--e161e330.34876a6f.js"><link rel="prefetch" href="/assets/js/page--e4f35ef4.690d3ccb.js"><link rel="prefetch" href="/assets/js/page--e501c270.8dc088ee.js"><link rel="prefetch" href="/assets/js/page--e9b9b570.b94764ed.js"><link rel="prefetch" href="/assets/js/page--ea4e0a70.94492571.js"><link rel="prefetch" href="/assets/js/page--ee71a870.b9944792.js"><link rel="prefetch" href="/assets/js/page--f21187b0.d00a5788.js"><link rel="prefetch" href="/assets/js/page--f6c97ab0.ecb91d64.js"><link rel="prefetch" href="/assets/js/page--fb816db0.c1f07c37.js"><link rel="prefetch" href="/assets/js/page--fcf2f51e.71000d71.js"><link rel="prefetch" href="/assets/js/page--ff214cf0.aaa8b0fc.js"><link rel="prefetch" href="/assets/js/page-GN.2f20b55f.js"><link rel="prefetch" href="/assets/js/page-GNFrequentlyAskedQuestions.24e61c26.js"><link rel="prefetch" href="/assets/js/page-GNLanguageandOperation.35e22ff2.js"><link rel="prefetch" href="/assets/js/page-GNQuickStartguide.7cd8e521.js"><link rel="prefetch" href="/assets/js/page-GNReference.1d5d0c6c.js"><link rel="prefetch" href="/assets/js/page-GNSimpleBuildExample.2eb0b7eb.js"><link rel="prefetch" href="/assets/js/page-GNStyleGuide.8a407135.js"><link rel="prefetch" href="/assets/js/page-GNU汇编教程.d208e4d7.js"><link rel="prefetch" href="/assets/js/page-GNvimsyntaxplugin.58d1459e.js"><link rel="prefetch" href="/assets/js/page-GN快速入门.b708bb6a.js"><link rel="prefetch" href="/assets/js/page-Home.97282d71.js"><link rel="prefetch" href="/assets/js/page-HowGNhandlescross-compiling.6ca64957.js"><link rel="prefetch" href="/assets/js/page-Introduction.292088e0.js"><link rel="prefetch" href="/assets/js/page-ninja快速入门.92729e64.js"><link rel="prefetch" href="/assets/js/page-《孙子兵法》全文.402792c5.js"><link rel="prefetch" href="/assets/js/page-《论语》全文.85da0da0.js"><link rel="prefetch" href="/assets/js/page-《诗经》全文.99ebeb52.js"><link rel="prefetch" href="/assets/js/page-《道德经》全文.43627e4e.js"><link rel="prefetch" href="/assets/js/page-两个文档.eb8dd1b7.js"><link rel="prefetch" href="/assets/js/page-主流站点覆盖定期同步更新.1ad02178.js"><link rel="prefetch" href="/assets/js/page-手机版电脑版.b5e8dfea.js"><link rel="prefetch" href="/assets/js/page-捐助方式.6ca91d44.js"><link rel="prefetch" href="/assets/js/page-来源LiteOS和LiteOS-A内核图解.8fa16705.js"><link rel="prefetch" href="/assets/js/page-电脑版手机版.67a0b4a4.js"><link rel="prefetch" href="/assets/js/page-编程语言相关书籍.d9adf7cb.js"><link rel="prefetch" href="/assets/js/page-鸿蒙内核源码分析.bbb451c7.js"><link rel="prefetch" href="/assets/js/vendors~flowchart.46b2de48.js"><link rel="prefetch" href="/assets/js/vendors~mermaid.627fb4be.js"><link rel="prefetch" href="/assets/js/vendors~photo-swipe.cbde97f9.js"><link rel="prefetch" href="/assets/js/vendors~reveal.77b21b7e.js">
    <link rel="stylesheet" href="/assets/css/0.styles.087eb7d3.css">
  </head>
  <body>
    <div id="app" data-server-rendered="true"><div class="theme-container has-navbar has-sidebar has-anchor"><header class="navbar"><!----> <div class="content__navbar-start"></div> <button title="Sidebar Button" class="sidebar-button"><span class="icon"></span></button> <a href="/" class="home-link router-link-active"><!----> <!----> <span class="site-name can-hide">中俊为 | we harmonyos</span></a> <!----> <div class="content__navbar-center"></div> <div class="links"><button tabindex="-1" aria-hidden="true" class="color-button"><svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" class="skin-icon"><path d="M224 800c0 9.6 3.2 44.8 6.4 54.4 6.4 48-48 76.8-48 76.8s80 41.6 147.2 0 134.4-134.4
        38.4-195.2c-22.4-12.8-41.6-19.2-57.6-19.2C259.2 716.8 227.2 761.6 224 800zM560 675.2l-32
        51.2c-51.2 51.2-83.2 32-83.2 32 25.6 67.2 0 112-12.8 128 25.6 6.4 51.2 9.6 80 9.6 54.4 0
        102.4-9.6 150.4-32l0 0c3.2 0 3.2-3.2 3.2-3.2 22.4-16 12.8-35.2
        6.4-44.8-9.6-12.8-12.8-25.6-12.8-41.6 0-54.4 60.8-99.2 137.6-99.2 6.4 0 12.8 0 22.4
        0 12.8 0 38.4 9.6 48-25.6 0-3.2 0-3.2 3.2-6.4 0-3.2 3.2-6.4 3.2-6.4 6.4-16 6.4-16 6.4-19.2
        9.6-35.2 16-73.6 16-115.2 0-105.6-41.6-198.4-108.8-268.8C704 396.8 560 675.2 560 675.2zM224
        419.2c0-28.8 22.4-51.2 51.2-51.2 28.8 0 51.2 22.4 51.2 51.2 0 28.8-22.4 51.2-51.2 51.2C246.4
        470.4 224 448 224 419.2zM320 284.8c0-22.4 19.2-41.6 41.6-41.6 22.4 0 41.6 19.2 41.6 41.6 0
        22.4-19.2 41.6-41.6 41.6C339.2 326.4 320 307.2 320 284.8zM457.6 208c0-12.8 12.8-25.6 25.6-25.6
        12.8 0 25.6 12.8 25.6 25.6 0 12.8-12.8 25.6-25.6 25.6C470.4 233.6 457.6 220.8 457.6 208zM128
        505.6C128 592 153.6 672 201.6 736c28.8-60.8 112-60.8 124.8-60.8-16-51.2 16-99.2
        16-99.2l316.8-422.4c-48-19.2-99.2-32-150.4-32C297.6 118.4 128 291.2 128 505.6zM764.8
        86.4c-22.4 19.2-390.4 518.4-390.4 518.4-22.4 28.8-12.8 76.8 22.4 99.2l9.6 6.4c35.2 22.4
        80 12.8 99.2-25.6 0 0 6.4-12.8 9.6-19.2 54.4-105.6 275.2-524.8 288-553.6
        6.4-19.2-3.2-32-19.2-32C777.6 76.8 771.2 80 764.8 86.4z"></path></svg> <div class="color-picker-menu" style="display:none;"><div class="theme-options"><ul class="themecolor-select"><label for="themecolor-select">Theme Color:</label> <li><span class="default-theme"></span></li> </ul> <div class="darkmode-toggle"><label for="darkmode-toggle" class="desc">Theme Mode:</label> <div class="darkmode-switch"><div class="item day"><svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" class="icon light-icon"><path d="M512 256a42.667 42.667 0 0 0 42.667-42.667V128a42.667 42.667 0 0 0-85.334 0v85.333A42.667 42.667 0 0 0 512 256zm384 213.333h-85.333a42.667 42.667 0 0 0 0 85.334H896a42.667 42.667 0 0 0 0-85.334zM256 512a42.667 42.667 0 0 0-42.667-42.667H128a42.667 42.667 0 0 0 0 85.334h85.333A42.667 42.667 0 0 0 256 512zm9.387-298.667a42.667 42.667 0 0 0-59.307 62.72l61.44 59.307a42.667 42.667 0 0 0 31.147 11.947 42.667 42.667 0 0 0 30.72-13.227 42.667 42.667 0 0 0 0-60.16zm459.946 133.974a42.667 42.667 0 0 0 29.44-11.947l61.44-59.307a42.667 42.667 0 0 0-57.6-62.72l-61.44 60.587a42.667 42.667 0 0 0 0 60.16 42.667 42.667 0 0 0 28.16 13.227zM512 768a42.667 42.667 0 0 0-42.667 42.667V896a42.667 42.667 0 0 0 85.334 0v-85.333A42.667 42.667 0 0 0 512 768zm244.48-79.36a42.667 42.667 0 0 0-59.307 61.44l61.44 60.587a42.667 42.667 0 0 0 29.44 11.946 42.667 42.667 0 0 0 30.72-12.8 42.667 42.667 0 0 0 0-60.586zm-488.96 0-61.44 59.307a42.667 42.667 0 0 0 0 60.586 42.667 42.667 0 0 0 30.72 12.8 42.667 42.667 0 0 0 28.587-10.666l61.44-59.307a42.667 42.667 0 0 0-59.307-61.44zM512 341.333A170.667 170.667 0 1 0 682.667 512 170.667 170.667 0 0 0 512 341.333z" fill="currentColor"></path></svg></div> <div class="item auto active"><svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" class="icon auto-icon"><path d="M460.864 539.072H564.8L510.592 376l-49.728 163.072zM872 362.368V149.504H659.648L510.528 0l-149.12 149.504H149.12v212.928L0 511.872l149.12 149.504v212.928h212.352l149.12 149.504 149.12-149.504h212.352V661.376l149.12-149.504L872 362.368zM614.464 693.12l-31.616-90.624H438.272l-31.616 90.624h-85.888l144.576-407.68h90.368l144.576 407.68h-85.824zm0 0" fill="currentColor"></path></svg></div> <div class="item night"><svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" class="icon dark-icon"><path d="M935.539 630.402c-11.43-11.432-28.674-14.739-43.531-8.354-46.734 20.103-96.363 30.297-147.508 30.297-99.59 0-193.221-38.784-263.64-109.203-108.637-108.637-139.61-270.022-78.908-411.148a39.497 39.497 0 0 0-51.886-51.887c-52.637 22.64-100.017 54.81-140.826 95.616-85.346 85.346-132.346 198.821-132.346 319.52 0 120.7 47.001 234.172 132.347 319.519S408.063 947.11 528.76 947.11c120.7 0 234.172-47.003 319.52-132.351 40.809-40.81 72.978-88.19 95.616-140.826a39.497 39.497 0 0 0-8.356-43.532z" fill="currentColor"></path></svg></div></div> <!----></div></div></div></button> <div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="/" class="nav-link router-link-active"><!---->
  首页
</a></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="文档中心" class="dropdown-title"><span class="title"><!---->
        文档中心
      </span> <span class="arrow"></span></button> <ul class="nav-dropdown"><li class="dropdown-item"><a href="http://open.weharmonyos.com/zh-cn/readme/Readme-CN.html" target="_blank" rel="noopener noreferrer" class="nav-link external"><!---->
  子系统
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li><li class="dropdown-item"><a href="http://open.weharmonyos.com/zh-cn/device-dev/website.html" target="_blank" rel="noopener noreferrer" class="nav-link external"><!---->
  南向
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li><li class="dropdown-item"><a href="http://open.weharmonyos.com/zh-cn/application-dev/website.html" target="_blank" rel="noopener noreferrer" class="nav-link external"><!---->
  北向
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="博客中心" class="dropdown-title"><span class="title"><!---->
        博客中心
      </span> <span class="arrow"></span></button> <ul class="nav-dropdown"><li class="dropdown-item"><a href="/blog/101.html" class="nav-link"><!---->
  总目录
</a></li><li class="dropdown-item"><a href="/blog/index/1_base.html" class="nav-link"><!---->
  基础知识
</a></li><li class="dropdown-item"><a href="/blog/index/2_process.html" class="nav-link"><!---->
  进程管理
</a></li><li class="dropdown-item"><a href="/blog/index/3_task.html" class="nav-link"><!---->
  任务管理
</a></li><li class="dropdown-item"><a href="/blog/index/4_mem.html" class="nav-link"><!---->
  内存管理
</a></li><li class="dropdown-item"><a href="/blog/index/5_ipc.html" class="nav-link"><!---->
  进程通讯
</a></li><li class="dropdown-item"><a href="/blog/index/6_fs.html" class="nav-link"><!---->
  文件系统
</a></li><li class="dropdown-item"><a href="/blog/index/7_hw.html" class="nav-link"><!---->
  软硬接口
</a></li><li class="dropdown-item"><a href="/blog/index/8_asm.html" class="nav-link"><!---->
  内核汇编
</a></li><li class="dropdown-item"><a href="/blog/index/9_run.html" class="nav-link"><!---->
  编译运行
</a></li><li class="dropdown-item"><a href="/blog/index/10_test.html" class="nav-link"><!---->
  调测工具
</a></li><li class="dropdown-item"><a href="/blog/index/0_so.html" class="nav-link"><!---->
  前因后果
</a></li><li class="dropdown-item"><a href="/extsite.html" class="nav-link"><!---->
  前往 &gt;&gt; 外站
</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="论坛中心" class="dropdown-title"><span class="title"><!---->
        论坛中心
      </span> <span class="arrow"></span></button> <ul class="nav-dropdown"><li class="dropdown-item"><a href="http://bbs.weharmonyos.com" target="_blank" rel="noopener noreferrer" class="nav-link external"><!---->
  论坛首页
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li><li class="dropdown-item"><a href="http://bbs.weharmonyos.com/forum-42-1.html" target="_blank" rel="noopener noreferrer" class="nav-link external"><!---->
  问题建议
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="手册中心" class="dropdown-title"><span class="title"><!---->
        手册中心
      </span> <span class="arrow"></span></button> <ul class="nav-dropdown"><li class="dropdown-item"><a href="http://doxygen.weharmonyos.com/index.html" target="_blank" rel="noopener noreferrer" class="nav-link external"><!---->
  内核参考手册
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li><li class="dropdown-item"><a href="/compile/assembly.html" class="nav-link"><!---->
  gnu 汇编教程
</a></li><li class="dropdown-item"><a href="/compile/gn/docs/" class="nav-link"><!---->
  gn 参考手册
</a></li><li class="dropdown-item"><a href="/compile/ninja/Readme-CN.html" class="nav-link"><!---->
  ninja 参考手册
</a></li><li class="dropdown-item"><a href="/compile/fhs.html" class="nav-link"><!---->
  fhs 规范
</a></li></ul></div></div><div class="nav-item"><a href="/donate.html" class="nav-link"><!---->
  赞助中心
</a></div></nav> <!----> <!----> <!----> <div class="content__navbar-end"></div></div></header> <div class="sidebar-mask"></div> <aside class="sidebar"><!----> <!----> <div class="content__sidebar-top"></div> <nav class="sidebar-nav-links"><div class="nav-item"><a href="/" class="nav-link router-link-active"><!---->
  首页
</a></div><div class="nav-item"><div class="mobile-dropdown-wrapper"><button type="button" aria-label="文档中心" class="dropdown-title"><span class="title"><!---->
      文档中心
    </span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="http://open.weharmonyos.com/zh-cn/readme/Readme-CN.html" target="_blank" rel="noopener noreferrer" class="nav-link external"><!---->
  子系统
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li><li class="dropdown-item"><!----> <a href="http://open.weharmonyos.com/zh-cn/device-dev/website.html" target="_blank" rel="noopener noreferrer" class="nav-link external"><!---->
  南向
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li><li class="dropdown-item"><!----> <a href="http://open.weharmonyos.com/zh-cn/application-dev/website.html" target="_blank" rel="noopener noreferrer" class="nav-link external"><!---->
  北向
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li></ul></div></div><div class="nav-item"><div class="mobile-dropdown-wrapper"><button type="button" aria-label="博客中心" class="dropdown-title"><span class="title"><!---->
      博客中心
    </span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/blog/101.html" class="nav-link"><!---->
  总目录
</a></li><li class="dropdown-item"><!----> <a href="/blog/index/1_base.html" class="nav-link"><!---->
  基础知识
</a></li><li class="dropdown-item"><!----> <a href="/blog/index/2_process.html" class="nav-link"><!---->
  进程管理
</a></li><li class="dropdown-item"><!----> <a href="/blog/index/3_task.html" class="nav-link"><!---->
  任务管理
</a></li><li class="dropdown-item"><!----> <a href="/blog/index/4_mem.html" class="nav-link"><!---->
  内存管理
</a></li><li class="dropdown-item"><!----> <a href="/blog/index/5_ipc.html" class="nav-link"><!---->
  进程通讯
</a></li><li class="dropdown-item"><!----> <a href="/blog/index/6_fs.html" class="nav-link"><!---->
  文件系统
</a></li><li class="dropdown-item"><!----> <a href="/blog/index/7_hw.html" class="nav-link"><!---->
  软硬接口
</a></li><li class="dropdown-item"><!----> <a href="/blog/index/8_asm.html" class="nav-link"><!---->
  内核汇编
</a></li><li class="dropdown-item"><!----> <a href="/blog/index/9_run.html" class="nav-link"><!---->
  编译运行
</a></li><li class="dropdown-item"><!----> <a href="/blog/index/10_test.html" class="nav-link"><!---->
  调测工具
</a></li><li class="dropdown-item"><!----> <a href="/blog/index/0_so.html" class="nav-link"><!---->
  前因后果
</a></li><li class="dropdown-item"><!----> <a href="/extsite.html" class="nav-link"><!---->
  前往 &gt;&gt; 外站
</a></li></ul></div></div><div class="nav-item"><div class="mobile-dropdown-wrapper"><button type="button" aria-label="论坛中心" class="dropdown-title"><span class="title"><!---->
      论坛中心
    </span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="http://bbs.weharmonyos.com" target="_blank" rel="noopener noreferrer" class="nav-link external"><!---->
  论坛首页
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li><li class="dropdown-item"><!----> <a href="http://bbs.weharmonyos.com/forum-42-1.html" target="_blank" rel="noopener noreferrer" class="nav-link external"><!---->
  问题建议
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li></ul></div></div><div class="nav-item"><div class="mobile-dropdown-wrapper"><button type="button" aria-label="手册中心" class="dropdown-title"><span class="title"><!---->
      手册中心
    </span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="http://doxygen.weharmonyos.com/index.html" target="_blank" rel="noopener noreferrer" class="nav-link external"><!---->
  内核参考手册
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li><li class="dropdown-item"><!----> <a href="/compile/assembly.html" class="nav-link"><!---->
  gnu 汇编教程
</a></li><li class="dropdown-item"><!----> <a href="/compile/gn/docs/" class="nav-link"><!---->
  gn 参考手册
</a></li><li class="dropdown-item"><!----> <a href="/compile/ninja/Readme-CN.html" class="nav-link"><!---->
  ninja 参考手册
</a></li><li class="dropdown-item"><!----> <a href="/compile/fhs.html" class="nav-link"><!---->
  fhs 规范
</a></li></ul></div></div><div class="nav-item"><a href="/donate.html" class="nav-link"><!---->
  赞助中心
</a></div> <!----></nav> <!----> <div class="content__sidebar-center"></div> <ul class="sidebar-links"><li><a href="/blog/101.html" class="sidebar-link">总目录</a></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading clickable"><!----> <span class="title">基础知识 | 10</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading clickable"><!----> <span class="title">进程管理 | 10</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading clickable"><!----> <span class="title">任务管理 | 10</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading clickable"><!----> <span class="title">内存管理 | 10</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading clickable"><!----> <span class="title">通讯机制 | 14</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading clickable"><!----> <span class="title">文件系统 | 10</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading clickable"><!----> <span class="title">硬件架构 | 9</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading clickable"><!----> <span class="title">内核汇编 | 10</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading clickable open"><!----> <span class="title">编译运行 | 13</span> <span class="arrow down"></span></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/blog/index/9_run.html" class="sidebar-link">本章目录</a></li><li><a href="/blog/84.html" class="sidebar-link">编译过程</a></li><li><a href="/blog/85.html" class="sidebar-link">编译构建</a></li><li><a href="/blog/86.html" class="sidebar-link">构建工具</a></li><li><a href="/blog/87.html" class="sidebar-link">忍者无敌</a></li><li><a href="/blog/88.html" aria-current="page" class="active sidebar-link">ELF格式</a><ul class="sidebar-sub-headers"></ul></li><li><a href="/blog/89.html" class="sidebar-link">ELF解析</a></li><li><a href="/blog/90.html" class="sidebar-link">静态链接</a></li><li><a href="/blog/91.html" class="sidebar-link">重定位</a></li><li><a href="/blog/92.html" class="sidebar-link">动态链接</a></li><li><a href="/blog/93.html" class="sidebar-link">进程映像</a></li><li><a href="/blog/94.html" class="sidebar-link">应用启动</a></li><li><a href="/blog/95.html" class="sidebar-link">系统调用</a></li><li><a href="/blog/96.html" class="sidebar-link">VDSO</a></li></ul></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading clickable"><!----> <span class="title">调测工具 | 4</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading clickable"><!----> <span class="title">前因后果 | 4</span> <span class="arrow right"></span></p> <!----></section></li></ul> <!----> <div class="content__sidebar-bottom"></div> <!----></aside> <main class="page"><nav class="breadcrumb disable"><!----></nav> <!----> <div class="content__page-top"></div> <div vocab="https://schema.org/" typeof="Article" class="page-title"><h1><!----> <span property="headline"></span></h1> <div class="page-info"><!----> </div> <!----> <hr></div> <div class="anchor-place-holder"><aside id="anchor"><div class="anchor-wrapper"><ul class="anchor-list"><li class="anchor"><a href="/blog/88.html#阅读之前的说明" class="anchor-link heading3"><div>阅读之前的说明</div></a></li><li class="anchor"><a href="/blog/88.html#示例代码" class="anchor-link heading3"><div>示例代码</div></a></li><li class="anchor"><a href="/blog/88.html#名正才言顺" class="anchor-link heading3"><div>名正才言顺</div></a></li><li class="anchor"><a href="/blog/88.html#elf历史" class="anchor-link heading3"><div>ELF历史</div></a></li><li class="anchor"><a href="/blog/88.html#elf整体布局" class="anchor-link heading3"><div>ELF整体布局</div></a></li><li class="anchor"><a href="/blog/88.html#elf头信息" class="anchor-link heading3"><div>ELF头信息</div></a></li><li class="anchor"><a href="/blog/88.html#段-segment-头信息" class="anchor-link heading3"><div>段(Segment)头信息</div></a></li><li class="anchor"><a href="/blog/88.html#区表" class="anchor-link heading3"><div>区表</div></a></li><li class="anchor"><a href="/blog/88.html#string-table" class="anchor-link heading3"><div>String Table</div></a></li><li class="anchor"><a href="/blog/88.html#符号表-symbol-table" class="anchor-link heading3"><div>符号表 Symbol Table</div></a></li><li class="anchor"><a href="/blog/88.html#反汇编代码区" class="anchor-link heading3"><div>反汇编代码区</div></a></li><li class="anchor"><a href="/blog/88.html#百文说内核-抓住主脉络" class="anchor-link heading3"><div>百文说内核 | 抓住主脉络</div></a></li><li class="anchor"><a href="/blog/88.html#百万注源码-处处扣细节" class="anchor-link heading3"><div>百万注源码 | 处处扣细节</div></a></li><li class="anchor"><a href="/blog/88.html#关注不迷路-代码即人生" class="anchor-link heading3"><div>关注不迷路 | 代码即人生</div></a></li></ul></div></aside></div> <!----> <div class="content__content-top"></div> <div class="theme-default-content content__default"><p>本篇关键词：、、、</p> <p><a href="https://weharmony.gitee.io/blog/88.html" target="_blank" rel="noopener noreferrer"><img src="https://weharmonyos.oss-cn-hangzhou.aliyuncs.com/resources/index/88.png" alt=""></a></p> <p><a href="https://weharmonyos.oss-cn-hangzhou.aliyuncs.com/resources/pdf/%E9%B8%BF%E8%92%99%E5%86%85%E6%A0%B8%E6%BA%90%E7%A0%81%E5%88%86%E6%9E%90(%E7%99%BE%E7%AF%87%E5%8D%9A%E5%AE%A2%E5%88%86%E6%9E%90.%E6%8C%96%E9%80%8F%E9%B8%BF%E8%92%99%E5%86%85%E6%A0%B8).zip" target="_blank" rel="noopener noreferrer">下载 &gt;&gt; 离线文档.鸿蒙内核源码分析(百篇博客分析.挖透鸿蒙内核).pdf</a></p> <p>编译运行相关篇为:</p> <ul><li><a href="http://weharmonyos.com/blog/84.html" target="_blank" rel="noopener noreferrer">v84.02 鸿蒙内核源码分析(编译过程) | 简单案例说透中间过程</a></li> <li><a href="http://weharmonyos.com/blog/85.html" target="_blank" rel="noopener noreferrer">v85.03 鸿蒙内核源码分析(编译构建) | 编译鸿蒙防掉坑指南</a></li> <li><a href="http://weharmonyos.com/blog/86.html" target="_blank" rel="noopener noreferrer">v86.04 鸿蒙内核源码分析(GN语法) | 如何构建鸿蒙系统</a></li> <li><a href="http://weharmonyos.com/blog/87.html" target="_blank" rel="noopener noreferrer">v87.03 鸿蒙内核源码分析(忍者无敌) | 忍者的特点就是一个字</a></li> <li><a href="http://weharmonyos.com/blog/88.html" target="_blank" rel="noopener noreferrer">v88.04 鸿蒙内核源码分析(ELF格式) | 应用程序入口并非main</a></li> <li><a href="http://weharmonyos.com/blog/89.html" target="_blank" rel="noopener noreferrer">v89.03 鸿蒙内核源码分析(ELF解析) | 敢忘了她姐俩你就不是银</a></li> <li><a href="http://weharmonyos.com/blog/90.html" target="_blank" rel="noopener noreferrer">v90.04 鸿蒙内核源码分析(静态链接) | 一个小项目看中间过程</a></li> <li><a href="http://weharmonyos.com/blog/91.html" target="_blank" rel="noopener noreferrer">v91.04 鸿蒙内核源码分析(重定位) | 与国际接轨的对外发言人</a></li> <li><a href="http://weharmonyos.com/blog/92.html" target="_blank" rel="noopener noreferrer">v92.01 鸿蒙内核源码分析(动态链接) | 正在制作中 ... </a></li> <li><a href="http://weharmonyos.com/blog/93.html" target="_blank" rel="noopener noreferrer">v93.05 鸿蒙内核源码分析(进程映像) | 程序是如何被加载运行的</a></li> <li><a href="http://weharmonyos.com/blog/94.html" target="_blank" rel="noopener noreferrer">v94.01 鸿蒙内核源码分析(应用启动) | 正在制作中 ... </a></li> <li><a href="http://weharmonyos.com/blog/95.html" target="_blank" rel="noopener noreferrer">v95.06 鸿蒙内核源码分析(系统调用) | 开发者永远的口头禅</a></li> <li><a href="http://weharmonyos.com/blog/96.html" target="_blank" rel="noopener noreferrer">v96.01 鸿蒙内核源码分析(VDSO) | 正在制作中 ... </a></li></ul> <h3 id="阅读之前的说明">阅读之前的说明</h3> <p>先说明，本篇很长，也很枯燥，若不是绝对的技术偏执狂是看不下去的。将通过一段简单代码去跟踪编译成ELF格式后的内容。看看<code>ELF</code>究竟长了怎样的一副花花肠子，用<code>readelf</code>命令去窥视ELF的全貌，最后用<code>objdump</code>命令反汇编<code>ELF</code>。找到了大家熟悉<code>main</code>函数。
开始之前先说结论:
ELF 分四块，其中三块是描述信息(也叫头信息)，另一块是内容，放的是所有段/区的内容。</p> <ul><li>1。 ELF头定义全局性信息</li> <li>2。 Segment(段)头，内容描述段的名字，开始位置，类型，偏移，大小及每段由哪些区组成。</li> <li>3。 内容区，ELF有两个重要概念 <code>Segment</code>(段) 和  <code>Section</code>(区)，段比区大，二者之间关系如下:
<ul><li>每个<code>Segment</code>可以包含多个<code>Section</code></li> <li>每个<code>Section</code>可以属于多个<code>Segment</code></li> <li><code>Segment</code>之间可以有重合的部分</li> <li>拿大家熟知的<code>.text</code>，<code>.data</code>，<code>。bss</code>举例，它们都叫区，但它们又属于<code>LOAD</code>段。</li></ul></li> <li>4。 Section(区)头，内容描述区的名字，开始位置，类型，偏移，大小等信息</li> <li>ELF一体两面，面对不同的场景扮演不同的角色，这是理解ELF的关键，链接器只关注1，3(区)，4 的内容，加载器只关注1，2，3(段)的内容</li> <li>鸿蒙对<code>EFL</code>的定义在 <code>kernel\extended\dynload\include\los_ld_elf_pri.h</code>文件中
<a href="https://gitee.com/weharmony/kernel_liteos_a_note" target="_blank" rel="noopener noreferrer"><img src="https://weharmonyos.oss-cn-hangzhou.aliyuncs.com/resources/51/Elf-layout.png" alt=""></a></li></ul> <h3 id="示例代码">示例代码</h3> <p>在windows目录<code>E:\harmony\docker\case_code_100</code>下创建 main。c文件，如下:</p> <div class="language-c line-numbers-mode"><pre class="language-c"><code><span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">include</span> <span class="token string">&lt;stdio.h&gt;</span></span>
<span class="token keyword">void</span> <span class="token function">say_hello</span><span class="token punctuation">(</span><span class="token keyword">char</span> <span class="token operator">*</span>who<span class="token punctuation">)</span>
<span class="token punctuation">{</span>
    <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">&quot;hello， %s!\n&quot;</span>， who<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
<span class="token keyword">char</span> <span class="token operator">*</span>my_name <span class="token operator">=</span> <span class="token string">&quot;harmony os&quot;</span><span class="token punctuation">;</span>

<span class="token keyword">int</span> <span class="token function">main</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
<span class="token punctuation">{</span>
    <span class="token function">say_hello</span><span class="token punctuation">(</span>my_name<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">return</span> <span class="token number">0</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>    
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br></div></div><p>因在</p> <p><a href="https://my.oschina.net/weharmony/blog/5028613" target="_blank" rel="noopener noreferrer">v50。xx (编译环境篇) | docker编译鸿蒙真的很香 </a></p> <p>篇中已做好了环境映射，所以文件会同时出现在docker中。编译生成<code>ELF</code>-&gt;运行-&gt;<code>readelf -h</code>查看<code>app</code>头部信息。</p> <div class="language- line-numbers-mode"><pre class="language-text"><code>root@5e3abe332c5a:/home/docker/case_code_100# ls
main.c
root@5e3abe332c5a:/home/docker/case_code_100# gcc -o app main.c
root@5e3abe332c5a:/home/docker/case_code_100# ls
app  main.c
root@5e3abe332c5a:/home/docker/case_code_100# ./app
hello， harmony os!
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br></div></div><h3 id="名正才言顺">名正才言顺</h3> <p>一下是关于ELF的所有中英名词对照。建议先仔细看一篇再看系列篇部分。</p> <div class="language- line-numbers-mode"><pre class="language-text"><code>可执行可连接格式 : ELF(Executable and Linking Format)
ELF文件头:ELF header
基地址:base address
动态连接器: dynamic linker
动态连接: dynamic linking
全局偏移量表: got(global offset table)
进程链接表: plt(Procedure Linkage Table) 
哈希表: hash table
初始化函数 : initialization function
连接编辑器 : link editor
目标文件 : object file
函数连接表 : procedure linkage table
程序头: program header
程序头表 : program header table
程序解析器 : program interpreter
重定位: relocation
共享目标 : shared object
区(节): section
区(节)头 : section header
区(节)表: section header table
段 : segment
字符串表 : string table
符号表: symbol table
终止函数 : termination function
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br></div></div><h3 id="elf历史">ELF历史</h3> <ul><li><p>ELF(Executable and Linking Format)，即&quot;可执行可连接格式&quot;，最初由UNIX系统实验室(UNIX System Laboratories – USL)做为应用程序二进制接口(Application Binary Interface - ABI)的一部分而制定和发布。是鸿蒙的主要可执行文件格式。</p></li> <li><p>ELF的最大特点在于它有比较广泛的适用性，通用的二进制接口定义使之可以平滑地移植到多种不同的操作环境上。这样，不需要为每一种操作系统都定义一套不同的接口，因此减少了软件的重复编码与编译，加强了软件的可移植性。</p></li></ul> <h3 id="elf整体布局">ELF整体布局</h3> <p>ELF规范中把ELF文件宽泛地称为&quot;目标文件 (object file)&quot;，这与我们平时的理解不同。一般地，我们把经过编译但没有连接的文件(比如Unix/Linux上的。o文件)称为目标文件，而ELF文件仅指连接好的可执行文件；在ELF规范中，所有符合ELF格式规范的都称为ELF文件，也称为目标文件，这两个名字是相同的，而经过编译但没有连接的文件则称为&quot;可重定位文件 (relocatable file)&quot;或&quot;待重定位文件 (relocatable file)&quot;。本文采用与此规范相同的命名方式，所以当提到可重定位文件时，一般可以理解为惯常所说的目标文件；而提到目标文件时，即指各种类型的ELF文件。</p> <p>ELF格式可以表达四种类型的二进制对象文件(object files):</p> <ul><li><p>可重定位文件(relocatable file)，用于与其它目标文件进行连接以构建可执行文件或动态链接库。可重定位文件就是常说的目标文件，由源文件编译而成，但还没有连接成可执行文件。在UNIX系统下，一般有扩展名&quot;.o&quot;。之所以称其为&quot;可重定位&quot;，是因为在这些文件中，如果引用到其它目标文件或库文件中定义的符号（变量或者函数）的话，只是给出一个名字，这里还并不知道这个符号在哪里，其具体的地址是什么。需要在连接的过程中，把对这些外部符号的引用重新定位到其真正定义的位置上，所以称目标文件为&quot;可重定位&quot;或者&quot;待重定位&quot;的。</p></li> <li><p>可执行文件(executable file)包含代码和数据，是可以直接运行的程序。其代码和数据都有固定的地址 （或相对于基地址的偏移 ），系统可根据这些地址信息把程序加载到内存执行。</p></li> <li><p>共享目标文件(shared object file)，即动态连接库文件。它在以下两种情况下被使用:第一，在连接过程中与其它动态链接库或可重定位文件一起构建新的目标文件；第二，在可执行文件被加载的过程中，被动态链接到新的进程中，成为运行代码的一部分。包含了代码和数据，这些数据是在链接时被链接器（ld）和运行时动态链接器（ld.so.l、libc.so.l、ld-linux.so.l）使用的。</p></li> <li><p>核心转储文件(core dump file，就是core dump文件)</p> <div class="language- line-numbers-mode"><pre class="language-text"><code>可重定位文件用在编译和链接阶段。
可执行文件用在程序运行阶段。
共享库则同时用在编译链接和运行阶段，本篇 app 就是个 DYN，可直接运行。
     Type:                              DYN (Shared object file)
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br></div></div></li></ul> <p>在不同阶段，我们可以用不同视角来理解<code>ELF</code>文件，整体布局如下图所示:</p> <p><a href="https://gitee.com/weharmony/kernel_liteos_a_note" target="_blank" rel="noopener noreferrer"><img src="https://weharmonyos.oss-cn-hangzhou.aliyuncs.com/resources/51/elf.png" alt="kernel_liteos_a_note"></a></p> <p>从上图可见，ELF格式文件整体可分为四大部分:</p> <ul><li><code>ELF Header</code>: 在文件的开始，描述整个文件的组织。即<code>readelf -h app</code>看到的内容</li> <li><code>Program Header Table</code>: 告诉系统如何创建进程映像。用来构造进程映像的目标文件必须具有程序头部表，可重定位文件可以不需要这个表。表描述所有段(Segment)信息，即<code>readelf -l app</code>看到的前半部分内容。</li> <li><code>Segments</code>:段(<code>Segment</code>)由若干区(<code>Section</code>)组成。是从加载器角度来描述 <code>ELF</code> 文件。加载器只关心 <code>ELF header</code>， <code>Program header table</code> 和 <code>Segment</code> 这三部分内容。 在加载阶段可以忽略 section header table 来处理程序（所以很多加固手段删除了<code>section header table</code>）</li> <li><code>Sections</code>: 是从链接器角度来描述 <code>ELF</code> 文件。 链接器只关心 <code>ELF header</code>，<code>Sections</code> 以及 <code>Section header table</code> 这三部分内容。在链接阶段，可以忽略 <code>program header table</code> 来处理文件。</li> <li><code>Section Header Table</code>:描述区(<code>Section</code>)信息的数组，每个元素对应一个区，通常包含在可重定位文件中，可执行文件中为可选(通常包含) 即<code>readelf -S app</code>看到的内容</li> <li>从图中可以看出 <code>Segment</code>:<code>Section</code>(M:N)是多对多的包含关系。<code>Segment</code>是由多个<code>Section</code>组成，<code>Section</code>也能属于多个段。</li></ul> <h3 id="elf头信息">ELF头信息</h3> <p><code>ELF</code>头部信息对应鸿蒙源码结构体为 <code>LDElf32Ehdr</code>， 各字段含义已一一注解，很容易理解。</p> <div class="language-c line-numbers-mode"><pre class="language-c"><code><span class="token comment">//kernel\extended\dynload\include\los_ld_elf_pri.h</span>
<span class="token comment">/* Elf header */</span>
<span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">define</span> <span class="token macro-name">LD_EI_NIDENT</span>           <span class="token expression"><span class="token number">16</span></span></span>
<span class="token keyword">typedef</span> <span class="token keyword">struct</span> <span class="token punctuation">{</span>
    UINT8       elfIdent<span class="token punctuation">[</span>LD_EI_NIDENT<span class="token punctuation">]</span><span class="token punctuation">;</span> <span class="token comment">/* Magic number and other info */</span><span class="token comment">//含前16个字节，又可细分成class、data、version等字段，具体含义不用太关心，只需知道前4个字节点包含`ELF`关键字，这样可以判断当前文件是否是ELF格式</span>
    UINT16      elfType<span class="token punctuation">;</span>                <span class="token comment">/* Object file type */</span><span class="token comment">//表示具体ELF类型，可重定位文件/可执行文件/共享库文件</span>
    UINT16      elfMachine<span class="token punctuation">;</span>             <span class="token comment">/* Architecture */</span><span class="token comment">//表示cpu架构</span>
    UINT32      elfVersion<span class="token punctuation">;</span>             <span class="token comment">/* Object file version */</span><span class="token comment">//表示文件版本号</span>
    UINT32      elfEntry<span class="token punctuation">;</span>               <span class="token comment">/* Entry point virtual address */</span><span class="token comment">//对应`Entry point address`，程序入口函数地址，通过进程虚拟地址空间地址表达</span>
    UINT32      elfPhoff<span class="token punctuation">;</span>               <span class="token comment">/* Program header table file offset */</span><span class="token comment">//对应`Start of program headers`，表示program header table在文件内的偏移位置</span>
    UINT32      elfShoff<span class="token punctuation">;</span>               <span class="token comment">/* Section header table file offset */</span><span class="token comment">//对应`Start of section headers`，表示section header table在文件内的偏移位置</span>
    UINT32      elfFlags<span class="token punctuation">;</span>               <span class="token comment">/* Processor-specific flags */</span><span class="token comment">//表示与CPU处理器架构相关的信息</span>
    UINT16      elfHeadSize<span class="token punctuation">;</span>            <span class="token comment">/* ELF header size in bytes */</span><span class="token comment">//对应`Size of this header`，表示本ELF header自身的长度</span>
    UINT16      elfPhEntSize<span class="token punctuation">;</span>           <span class="token comment">/* Program header table entry size */</span><span class="token comment">//对应`Size of program headers`，表示program header table中每个元素的大小</span>
    UINT16      elfPhNum<span class="token punctuation">;</span>               <span class="token comment">/* Program header table entry count */</span><span class="token comment">//对应`Number of program headers`，表示program header table中元素个数</span>
    UINT16      elfShEntSize<span class="token punctuation">;</span>           <span class="token comment">/* Section header table entry size */</span><span class="token comment">//对应`Size of section headers`，表示section header table中每个元素的大小</span>
    UINT16      elfShNum<span class="token punctuation">;</span>               <span class="token comment">/* Section header table entry count */</span><span class="token comment">//对应`Number of section headers`，表示section header table中元素的个数</span>
    UINT16      elfShStrIndex<span class="token punctuation">;</span>          <span class="token comment">/* Section header string table index */</span><span class="token comment">//对应`Section header string table index`，表示描述各section字符名称的string table在section header table中的下标</span>
<span class="token punctuation">}</span> LDElf32Ehdr<span class="token punctuation">;</span>
root@<span class="token number">5e3</span>abe332c5a<span class="token operator">:</span><span class="token operator">/</span>home<span class="token operator">/</span>docker<span class="token operator">/</span>case_code_100# readelf <span class="token operator">-</span>h app
ELF Header<span class="token operator">:</span>
  Magic<span class="token operator">:</span>   <span class="token number">7f</span> <span class="token number">45</span> <span class="token number">4</span>c <span class="token number">46</span> <span class="token number">02</span> <span class="token number">01</span> <span class="token number">01</span> <span class="token number">00</span> <span class="token number">00</span> <span class="token number">00</span> <span class="token number">00</span> <span class="token number">00</span> <span class="token number">00</span> <span class="token number">00</span> <span class="token number">00</span> <span class="token number">00</span>
  Class<span class="token operator">:</span>                             ELF64
  Data<span class="token operator">:</span>                              <span class="token number">2</span>'s complement， little endian
  Version<span class="token operator">:</span>                           <span class="token number">1</span> <span class="token punctuation">(</span>current<span class="token punctuation">)</span>
  OS<span class="token operator">/</span>ABI<span class="token operator">:</span>                            UNIX <span class="token operator">-</span> System V
  ABI Version<span class="token operator">:</span>                       <span class="token number">0</span>
  Type<span class="token operator">:</span>                              <span class="token function">DYN</span> <span class="token punctuation">(</span>Shared object file<span class="token punctuation">)</span>
  Machine<span class="token operator">:</span>                           Advanced Micro Devices X86<span class="token operator">-</span><span class="token number">64</span>
  Version<span class="token operator">:</span>                           <span class="token number">0x1</span>
  Entry point address<span class="token operator">:</span>               <span class="token number">0x1060</span>
  Start of program headers<span class="token operator">:</span>          <span class="token number">64</span> <span class="token punctuation">(</span>bytes into file<span class="token punctuation">)</span>
  Start of section headers<span class="token operator">:</span>          <span class="token number">14784</span> <span class="token punctuation">(</span>bytes into file<span class="token punctuation">)</span>
  Flags<span class="token operator">:</span>                             <span class="token number">0x0</span>
  Size of this header<span class="token operator">:</span>               <span class="token number">64</span> <span class="token punctuation">(</span>bytes<span class="token punctuation">)</span>
  Size of program headers<span class="token operator">:</span>           <span class="token number">56</span> <span class="token punctuation">(</span>bytes<span class="token punctuation">)</span>
  Number of program headers<span class="token operator">:</span>         <span class="token number">13</span>
  Size of section headers<span class="token operator">:</span>           <span class="token number">64</span> <span class="token punctuation">(</span>bytes<span class="token punctuation">)</span>
  Number of section headers<span class="token operator">:</span>         <span class="token number">31</span>
  Section header string table index<span class="token operator">:</span> <span class="token number">30</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br><span class="line-number">31</span><br><span class="line-number">32</span><br><span class="line-number">33</span><br><span class="line-number">34</span><br><span class="line-number">35</span><br><span class="line-number">36</span><br><span class="line-number">37</span><br><span class="line-number">38</span><br><span class="line-number">39</span><br><span class="line-number">40</span><br></div></div><p><strong>解读</strong></p> <p>显示的信息，就是 ELF header 中描述的所有内容了。这个内容与结构体 <code>LDElf32Ehdr</code> 中的成员变量是一一对应的！
<code>Size of this header: 64 (bytes)</code>也就是说：ELF header 部分的内容，一共是 64 个字节。64个字节码长啥样可以用命令<code>od -Ax -t x1 -N 64 app</code>看，并对照结构体<code>LDElf32Ehdr</code>来理解。</p> <div class="language- line-numbers-mode"><pre class="language-text"><code>root@5e3abe332c5a:/home/docker/case_code_100/51# od -Ax -t x1 -N 64 app
000000 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00
000010 03 00 3e 00 01 00 00 00 60 10 00 00 00 00 00 00
000020 40 00 00 00 00 00 00 00 c0 39 00 00 00 00 00 00
000030 00 00 00 00 40 00 38 00 0d 00 40 00 1f 00 1e 00
000040
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br></div></div><p>简单解释一下命令的几个选项：</p> <div class="language- line-numbers-mode"><pre class="language-text"><code>-Ax: 显示地址的时候，用十六进制来表示。如果使用 -Ad，意思就是用十进制来显示地址;
-t -x1: 显示字节码内容的时候，使用十六进制(x)，每次显示一个字节(1);
-N 64：只需要读取64个字节;
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><p>这里留意这几个内容，下面会说明，先记住。</p> <div class="language- line-numbers-mode"><pre class="language-text"><code>Entry point address:               0x1060   //代码区 .text 起始位置，即程序运行开始位置
Size of program headers:           56 (bytes)//每个段头大小
Number of program headers:         13       //段数量
Size of section headers:           64 (bytes)//每个区头大小
Number of section headers:         31       //区数量
Section header string table index: 30       //字符串数组索引，该区记录所有区名称
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br></div></div><h3 id="段-segment-头信息">段(Segment)头信息</h3> <p>段(Segment)信息对应鸿蒙源码结构体为 <code>LDElf32Phdr</code>，</p> <div class="language- line-numbers-mode"><pre class="language-text"><code>//kernel\extended\dynload\include\los_ld_elf_pri.h
/* Program Header */
typedef struct {
    UINT32 type;     /* Segment type */	//段类型
    UINT32 offset;   /* Segment file offset */		//此数据成员给出本段内容在文件中的位置，即段内容的开始位置相对于文件开头的偏移量。
    UINT32 vAddr;    /* Segment virtual address */	//此数据成员给出本段内容的开始位置在进程空间中的虚拟地址。
    UINT32 phyAddr;  /* Segment physical address */	//此数据成员给出本段内容的开始位置在进程空间中的物理地址。对于目前大多数现代操作系统而言，应用程序中段的物理地址事先是不可知的，所以目前这个成员多数情况下保留不用，或者被操作系统改作它用。
    UINT32 fileSize; /* Segment size in file */		//此数据成员给出本段内容在文件中的大小，单位是字节，可以是0。
    UINT32 memSize;  /* Segment size in memory */	//此数据成员给出本段内容在内容镜像中的大小，单位是字节，可以是0。
    UINT32 flags;    /* Segment flags */			//此数据成员给出了本段内容的属性。
    UINT32 align;    /* Segment alignment */		//对于可装载的段来说，其p_vaddr和p_offset的值至少要向内存页面大小对齐。
} LDElf32Phdr;
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br></div></div><p><strong>解读</strong></p> <p>用<code>readelf -l</code>查看<code>app</code>段头部表内容，先看命令返回的前半部分:</p> <div class="language- line-numbers-mode"><pre class="language-text"><code>root@5e3abe332c5a:/home/docker/case_code_100# readelf -l app 
Elf file type is DYN (Shared object file)
Entry point 0x1060
There are 13 program headers， starting at offset 64
Program Headers:
  Type           Offset             VirtAddr           PhysAddr
                 FileSiz            MemSiz              Flags  Align
  PHDR           0x0000000000000040 0x0000000000000040 0x0000000000000040
                 0x00000000000002d8 0x00000000000002d8  R      0x8
  INTERP         0x0000000000000318 0x0000000000000318 0x0000000000000318
                 0x000000000000001c 0x000000000000001c  R      0x1
      [Requesting program interpreter: /lib64/ld-linux-x86-64.so。2]
  LOAD           0x0000000000000000 0x0000000000000000 0x0000000000000000
                 0x0000000000000618 0x0000000000000618  R      0x1000
  LOAD           0x0000000000001000 0x0000000000001000 0x0000000000001000
                 0x0000000000000225 0x0000000000000225  R E    0x1000
  LOAD           0x0000000000002000 0x0000000000002000 0x0000000000002000
                 0x0000000000000190 0x0000000000000190  R      0x1000
  LOAD           0x0000000000002db8 0x0000000000003db8 0x0000000000003db8
                 0x0000000000000260 0x0000000000000268  RW     0x1000
  DYNAMIC        0x0000000000002dc8 0x0000000000003dc8 0x0000000000003dc8
                 0x00000000000001f0 0x00000000000001f0  RW     0x8
  NOTE           0x0000000000000338 0x0000000000000338 0x0000000000000338
                 0x0000000000000020 0x0000000000000020  R      0x8
  NOTE           0x0000000000000358 0x0000000000000358 0x0000000000000358
                 0x0000000000000044 0x0000000000000044  R      0x4
  GNU_PROPERTY   0x0000000000000338 0x0000000000000338 0x0000000000000338
                 0x0000000000000020 0x0000000000000020  R      0x8
  GNU_EH_FRAME   0x000000000000201c 0x000000000000201c 0x000000000000201c
                 0x000000000000004c 0x000000000000004c  R      0x4
  GNU_STACK      0x0000000000000000 0x0000000000000000 0x0000000000000000
                 0x0000000000000000 0x0000000000000000  RW     0x10
  GNU_RELRO      0x0000000000002db8 0x0000000000003db8 0x0000000000003db8
                 0x0000000000000248 0x0000000000000248  R      0x1
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br><span class="line-number">31</span><br><span class="line-number">32</span><br><span class="line-number">33</span><br><span class="line-number">34</span><br></div></div><p>数一下一共13个段，其实在ELF头信息也告诉了我们共13个段</p> <div class="language- line-numbers-mode"><pre class="language-text"><code>Size of program headers:           56 (bytes)//每个段头大小
Number of program headers:         13       //段数量
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>仔细看下这些段的开始地址和大小，发现有些段是重叠的。那是因为一个区可以被多个段所拥有。例如:<code>0x2db8</code> 对应的 <code>.init_array</code>区就被第四<code>LOAD</code> 和 <code>GNU_RELRO</code>两段所共有。</p> <p><code>PHDR</code>，此类型header元素描述了program header table自身的信息。从这里的内容看出，示例程序的program header table在文件中的偏移(<code>Offset</code>)为<code>0x40</code>，即64号字节处。该段映射到进程空间的虚拟地址(<code>VirtAddr</code>)为<code>0x40</code>。<code>PhysAddr</code>暂时不用，其保持和<code>VirtAddr</code>一致。该段占用的文件大小<code>FileSiz</code>为<code>0x2d8</code>。运行时占用进程空间内存大小<code>MemSiz</code>也为<code>0x2d8</code>。<code>Flags</code>标记表示该段的读写权限，这里<code>R</code>表示只读，<code>Align</code>对齐为8，表明本段按8字节对齐。</p> <p><code>INTERP</code>，此类型header元素描述了一个特殊内存段，该段内存记录了动态加载解析器的访问路径字符串。示例程序中，该段内存位于文件偏移<code>0x318</code>处，即紧跟program header table。映射的进程虚拟地址空间地址为<code>0x318</code>。文件长度和内存映射长度均为<code>0x1c</code>，即28个字符，具体内容为<code>/lib64/ld-linux-x86-64.so。2</code>。段属性为只读，并按字节对齐。</p> <p><code>LOAD</code>，此类型<code>header</code>元素描述了可加载到进程空间的代码区或数据区:</p> <ul><li>其第二段包含了代码区，文件内偏移为0x1000，文件大小为0x225，映射到进程地址0x001000处，属性为只读可执行(RE)，段地址按0x1000(4K)边界对齐。</li> <li>其第四段包含了数据区，文件内偏移为0x2db8，文件大小为0x260，映射到进程地址0x003db8处，属性为可读可写(RW)，段地址也按0x1000(4K)边界对齐。</li></ul> <p><code>DYNAMIC</code>，此类型<code>header</code>元素描述了动态加载段，其内部通常包含了一个名为<code>。dynamic</code>的动态加载区。这也是一个数组，每个元素描述了与动态加载相关的各方面信息，将在系列篇(动态加载篇)中介绍。该段是从文件偏移<code>0x2dc8</code>处开始，长度为<code>0x1f0</code>，并映射到进程的<code>0x3dc8</code>。可见该段和上一个段<code>LOAD4 0x2db8</code>是有重叠的。</p> <p><code>GNU_STACK</code>，可执行栈，即栈区，在加载段的过程中，当发现存在PT_GNU_STACK，也就是GNU_STACK segment 的存在，如果存在这个这个段的话，看这个段的 flags 是否有可执行权限，来设置对应的值。必须为RW方式。</p> <p>再看命令返回内容的后半部分-段区映射关系</p> <div class="language- line-numbers-mode"><pre class="language-text"><code> Section to Segment mapping:
  Segment Sections...
   00
   01     .interp
   02     .interp .note.gnu.property .note.gnu.build-id .note.ABI-tag .gnu.hash .dynsym .dynstr .gnu.version .gnu.version_r .rela.dyn .rela.plt
   03     .init .plt .plt.got .plt.sec .text .fini
   04     .rodata .eh_frame_hdr .eh_frame
   05     .init_array .fini_array .dynamic .got .data .bss
   06     .dynamic
   07     .note.gnu.property
   08     .note.gnu.build-id .note.ABI-tag
   09     .note.gnu.property
   10     .eh_frame_hdr
   11
   12     .init_array .fini_array .dynamic .got
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br></div></div><p>13个段和31个区的映射关系，右边其实不止31个区，是因为一个区可以共属于多个段，例如 <code>.dynamic</code> ，<code>.interp</code>，<code>.got</code>
Segment:Section(M:N)是多对多的包含关系.Segment是由多个Section组成，Section也能属于多个段。这个很重要，说第二遍了。</p> <ul><li><code>INTERP</code>段只包含了<code>.interp</code>区</li> <li><code>LOAD2</code>段包含<code>.interp</code>、<code>.plt</code>、<code>.text</code>等区，<code>.text</code>代码区位于这个段。 这个段是 'RE'属性，只读可执行的。</li> <li><code>LOAD4</code>包含<code>.dynamic</code>、<code>.data</code>、<code>.bss</code>等区， 数据区位于这个段。这个段是 'RW'属性，可读可写。 <code>.data</code>、<code>.bss</code>都是数据区，有何区别呢？</li> <li><code>.data(ZI data)</code>它用来存放初始化了的(initailized)全局变量(global)和初始化了的静态变量(static)。</li> <li><code>.bss(RW data )</code>它用来存放未初始化的(uninitailized)全局变量(global)和未初始化的静态变量。</li> <li><code>DYNAMIC</code>段包含<code>.dynamic</code>区。</li></ul> <h3 id="区表">区表</h3> <p>区(section)头表信息对应鸿蒙源码结构体为 <code>LDElf32Shdr</code>，</p> <div class="language-c line-numbers-mode"><pre class="language-c"><code><span class="token comment">//kernel\extended\dynload\include\los_ld_elf_pri.h</span>
<span class="token comment">/* Section header */</span>
<span class="token keyword">typedef</span> <span class="token keyword">struct</span> <span class="token punctuation">{</span>
    UINT32 shName<span class="token punctuation">;</span>      <span class="token comment">/* Section name (string tbl index) */</span><span class="token comment">//表示每个区的名字</span>
    UINT32 shType<span class="token punctuation">;</span>      <span class="token comment">/* Section type */</span><span class="token comment">//表示每个区的功能</span>
    UINT32 shFlags<span class="token punctuation">;</span>     <span class="token comment">/* Section flags */</span><span class="token comment">//表示每个区的属性</span>
    UINT32 shAddr<span class="token punctuation">;</span>      <span class="token comment">/* Section virtual addr at execution */</span><span class="token comment">//表示每个区的进程映射地址</span>
    UINT32 shOffset<span class="token punctuation">;</span>    <span class="token comment">/* Section file offset */</span><span class="token comment">//表示文件内偏移</span>
    UINT32 shSize<span class="token punctuation">;</span>      <span class="token comment">/* Section size in bytes */</span><span class="token comment">//表示区的大小</span>
    UINT32 shLink<span class="token punctuation">;</span>      <span class="token comment">/* Link to another section */</span><span class="token comment">//Link和Info记录不同类型区的相关信息</span>
    UINT32 shInfo<span class="token punctuation">;</span>      <span class="token comment">/* Additional section information */</span><span class="token comment">//Link和Info记录不同类型区的相关信息</span>
    UINT32 shAddrAlign<span class="token punctuation">;</span> <span class="token comment">/* Section alignment */</span><span class="token comment">//表示区的对齐单位</span>
    UINT32 shEntSize<span class="token punctuation">;</span>   <span class="token comment">/* Entry size if section holds table */</span><span class="token comment">//表示区中每个元素的大小(如果该区为一个数组的话，否则该值为0)</span>
<span class="token punctuation">}</span> LDElf32Shdr<span class="token punctuation">;</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br></div></div><p>示例程序共生成31个区。其实在头文件中也已经告诉我们了</p> <div class="language- line-numbers-mode"><pre class="language-text"><code>Size of section headers:           64 (bytes)//每个区头大小
Number of section headers:         31       //区数量
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>通过<code>readelf -S</code>命令看看示例程序中 section header table的内容，如下所示。</p> <div class="language- line-numbers-mode"><pre class="language-text"><code>root@5e3abe332c5a:/home/docker/case_code_100# readelf -S app
There are 31 section headers， starting at offset 0x39c0:

Section Headers:
  [Nr] Name              Type             Address           Offset
       Size              EntSize          Flags  Link  Info  Align
  [ 0]                   NULL             0000000000000000  00000000
       0000000000000000  0000000000000000           0     0     0
  [ 1] .interp           PROGBITS         0000000000000318  00000318
       000000000000001c  0000000000000000   A       0     0     1
  [ 2] .note.gnu.propert NOTE             0000000000000338  00000338
       0000000000000020  0000000000000000   A       0     0     8
  [ 3] .note.gnu.build-i NOTE             0000000000000358  00000358
       0000000000000024  0000000000000000   A       0     0     4
  [ 4] .note.ABI-tag     NOTE             000000000000037c  0000037c
       0000000000000020  0000000000000000   A       0     0     4
  [ 5] .gnu.hash         GNU_HASH         00000000000003a0  000003a0
       0000000000000024  0000000000000000   A       6     0     8
  [ 6] .dynsym           DYNSYM           00000000000003c8  000003c8
       00000000000000a8  0000000000000018   A       7     1     8
  [ 7] .dynstr           STRTAB           0000000000000470  00000470
       0000000000000084  0000000000000000   A       0     0     1
  [ 8] .gnu.version      VERSYM           00000000000004f4  000004f4
       000000000000000e  0000000000000002   A       6     0     2
  [ 9] .gnu.version_r    VERNEED          0000000000000508  00000508
       0000000000000020  0000000000000000   A       7     1     8
  [10] .rela.dyn         RELA             0000000000000528  00000528
       00000000000000d8  0000000000000018   A       6     0     8
  [11] .rela.plt         RELA             0000000000000600  00000600
       0000000000000018  0000000000000018  AI       6    24     8
  [12] .init             PROGBITS         0000000000001000  00001000
       000000000000001b  0000000000000000  AX       0     0     4
  [13] .plt              PROGBITS         0000000000001020  00001020
       0000000000000020  0000000000000010  AX       0     0     16
  [14] .plt.got          PROGBITS         0000000000001040  00001040
       0000000000000010  0000000000000010  AX       0     0     16
  [15] .plt.sec          PROGBITS         0000000000001050  00001050
       0000000000000010  0000000000000010  AX       0     0     16
  [16] .text             PROGBITS         0000000000001060  00001060
       00000000000001b5  0000000000000000  AX       0     0     16
  [17] .fini             PROGBITS         0000000000001218  00001218
       000000000000000d  0000000000000000  AX       0     0     4
  [18] .rodata           PROGBITS         0000000000002000  00002000
       000000000000001b  0000000000000000   A       0     0     4
  [19] .eh_frame_hdr     PROGBITS         000000000000201c  0000201c
       000000000000004c  0000000000000000   A       0     0     4
  [20] .eh_frame         PROGBITS         0000000000002068  00002068
       0000000000000128  0000000000000000   A       0     0     8
  [21] .init_array       INIT_ARRAY       0000000000003db8  00002db8
       0000000000000008  0000000000000008  WA       0     0     8
  [22] .fini_array       FINI_ARRAY       0000000000003dc0  00002dc0
       0000000000000008  0000000000000008  WA       0     0     8
  [23] .dynamic          DYNAMIC          0000000000003dc8  00002dc8
       00000000000001f0  0000000000000010  WA       7     0     8
  [24] .got              PROGBITS         0000000000003fb8  00002fb8
       0000000000000048  0000000000000008  WA       0     0     8
  [25] .data             PROGBITS         0000000000004000  00003000
       0000000000000018  0000000000000000  WA       0     0     8
  [26] .bss              NOBITS           0000000000004018  00003018
       0000000000000008  0000000000000000  WA       0     0     1
  [27] .comment          PROGBITS         0000000000000000  00003018
       000000000000002a  0000000000000001  MS       0     0     1
  [28] .symtab           SYMTAB           0000000000000000  00003048
       0000000000000648  0000000000000018          29    46     8
  [29] .strtab           STRTAB           0000000000000000  00003690
       0000000000000216  0000000000000000           0     0     1
  [30] .shstrtab         STRTAB           0000000000000000  000038a6
       000000000000011a  0000000000000000           0     0     1
Key to Flags:
  W (write)， A (alloc)， X (execute)， M (merge)， S (strings)， I (info)，
  L (link order)， O (extra OS processing required)， G (group)， T (TLS)，
  C (compressed)， x (unknown)， o (OS specific)， E (exclude)，
  l (large)， p (processor specific)
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br><span class="line-number">31</span><br><span class="line-number">32</span><br><span class="line-number">33</span><br><span class="line-number">34</span><br><span class="line-number">35</span><br><span class="line-number">36</span><br><span class="line-number">37</span><br><span class="line-number">38</span><br><span class="line-number">39</span><br><span class="line-number">40</span><br><span class="line-number">41</span><br><span class="line-number">42</span><br><span class="line-number">43</span><br><span class="line-number">44</span><br><span class="line-number">45</span><br><span class="line-number">46</span><br><span class="line-number">47</span><br><span class="line-number">48</span><br><span class="line-number">49</span><br><span class="line-number">50</span><br><span class="line-number">51</span><br><span class="line-number">52</span><br><span class="line-number">53</span><br><span class="line-number">54</span><br><span class="line-number">55</span><br><span class="line-number">56</span><br><span class="line-number">57</span><br><span class="line-number">58</span><br><span class="line-number">59</span><br><span class="line-number">60</span><br><span class="line-number">61</span><br><span class="line-number">62</span><br><span class="line-number">63</span><br><span class="line-number">64</span><br><span class="line-number">65</span><br><span class="line-number">66</span><br><span class="line-number">67</span><br><span class="line-number">68</span><br><span class="line-number">69</span><br><span class="line-number">70</span><br><span class="line-number">71</span><br><span class="line-number">72</span><br><span class="line-number">73</span><br></div></div><h3 id="string-table">String Table</h3> <p>在 ELF header 的最后 <code>2</code> 个字节是 <code>0x1e</code> <code>0x00</code>，即<code>30</code>。 它对应结构体中的成员 <code>elfShStrIndex</code>，意思是这个 <code>ELF</code> 文件中，字符串表是一个普通的 <code>Section</code>，在这个 <code>Section</code> 中，存储了 <code>ELF</code> 文件中使用到的所有的字符串。
我们使用<code>readelf -x</code>读出下标30区的数据:</p> <div class="language- line-numbers-mode"><pre class="language-text"><code>root@5e3abe332c5a:/home/docker/case_code_100# readelf -x 30 app 

Hex dump of section '.shstrtab':
  0x00000000 002e7379 6d746162 002e7374 72746162 ..symtab..strtab
  0x00000010 002e7368 73747274 6162002e 696e7465 ..shstrtab..inte
  0x00000020 7270002e 6e6f7465 2e676e75 2e70726f rp..note.gnu.pro
  0x00000030 70657274 79002e6e 6f74652e 676e752e perty..note.gnu.
  0x00000040 6275696c 642d6964 002e6e6f 74652e41 build-id..note.A
  0x00000050 42492d74 6167002e 676e752e 68617368 BI-tag..gnu.hash
  0x00000060 002e6479 6e73796d 002e6479 6e737472 ..dynsym..dynstr
  0x00000070 002e676e 752e7665 7273696f 6e002e67 ..gnu.version..g
  0x00000080 6e752e76 65727369 6f6e5f72 002e7265 nu.version_r..re
  0x00000090 6c612e64 796e002e 72656c61 2e706c74 la.dyn..rela.plt
  0x000000a0 002e696e 6974002e 706c742e 676f7400 ..init..plt.got.
  0x000000b0 2e706c74 2e736563 002e7465 7874002e .plt.sec..text..
  0x000000c0 66696e69 002e726f 64617461 002e6568 fini..rodata..eh
  0x000000d0 5f667261 6d655f68 6472002e 65685f66 _frame_hdr..eh_f
  0x000000e0 72616d65 002e696e 69745f61 72726179 rame..init_array
  0x000000f0 002e6669 6e695f61 72726179 002e6479 ..fini_array..dy
  0x00000100 6e616d69 63002e64 61746100 2e627373 namic..data..bss
  0x00000110 002e636f 6d6d656e 7400              ..comment.
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br></div></div><p>可以发现，这里其实是一堆字符串，这些字符串对应的就是各个区的名字。因此section header table中每个元素的Name字段其实是这个string table的索引。为节省空间而做的设计，再回头看看ELF header中的 <code>elfShStrIndex</code>，</p> <div class="language- line-numbers-mode"><pre class="language-text"><code>Section header string table index: 30 //字符串数组索引，该区记录所有区名称
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><p>它的值正好就是30，指向了当前的string table。</p> <h3 id="符号表-symbol-table">符号表 Symbol Table</h3> <p>Section Header Table中，还有一类<code>SYMTAB</code>(DYNSYM)区，该区叫符号表。符号表中的每个元素对应一个符号，记录了每个符号对应的实际数值信息，通常用在重定位过程中或问题定位过程中，进程执行阶段并不加载符号表。符号表对应鸿蒙源码结构体为 <code>LDElf32Sym</code>。
//kernel\extended\dynload\include\los_ld_elf_pri.h</p> <div class="language-c line-numbers-mode"><pre class="language-c"><code><span class="token comment">/* Symbol table */</span>
<span class="token keyword">typedef</span> <span class="token keyword">struct</span> <span class="token punctuation">{</span>
    UINT32 stName<span class="token punctuation">;</span>  <span class="token comment">/* Symbol table name (string tbl index) */</span><span class="token comment">//表示符号对应的源码字符串，为对应String Table中的索引</span>
    UINT32 stValue<span class="token punctuation">;</span> <span class="token comment">/* Symbol table value */</span><span class="token comment">//表示符号对应的数值</span>
    UINT32 stSize<span class="token punctuation">;</span>  <span class="token comment">/* Symbol table size */</span><span class="token comment">//表示符号对应数值的空间占用大小</span>
    UINT8 stInfo<span class="token punctuation">;</span>   <span class="token comment">/* Symbol table type and binding */</span><span class="token comment">//表示符号的相关信息 如符号类型(变量符号、函数符号)</span>
    UINT8 stOther<span class="token punctuation">;</span>  <span class="token comment">/* Symbol table visibility */</span>
    UINT16 stShndx<span class="token punctuation">;</span> <span class="token comment">/* Section table index */</span><span class="token comment">//表示与该符号相关的区的索引，例如函数符号与对应的代码区相关</span>
<span class="token punctuation">}</span> LDElf32Sym<span class="token punctuation">;</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br></div></div><p>用<code>readelf -s</code>读出示例程序中的符号表，如下所示</p> <div class="language- line-numbers-mode"><pre class="language-text"><code>root@5e3abe332c5a:/home/docker/case_code_100# readelf -s app

Symbol table '.dynsym' contains 7 entries:
   Num:    Value          Size Type    Bind   Vis      Ndx Name
     0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT  UND
     1: 0000000000000000     0 NOTYPE  WEAK   DEFAULT  UND _ITM_deregisterTMCloneTab
     2: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND printf@GLIBC_2.2.5 (2)
     3: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND __libc_start_main@GLIBC_2.2.5 (2)
     4: 0000000000000000     0 NOTYPE  WEAK   DEFAULT  UND __gmon_start__
     5: 0000000000000000     0 NOTYPE  WEAK   DEFAULT  UND _ITM_registerTMCloneTable
     6: 0000000000000000     0 FUNC    WEAK   DEFAULT  UND __cxa_finalize@GLIBC_2.2.5 (2)

Symbol table '.symtab' contains 67 entries:
   Num:    Value          Size Type    Bind   Vis      Ndx Name
     0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT  UND
     1: 0000000000000318     0 SECTION LOCAL  DEFAULT    1
     2: 0000000000000338     0 SECTION LOCAL  DEFAULT    2
     3: 0000000000000358     0 SECTION LOCAL  DEFAULT    3
     4: 000000000000037c     0 SECTION LOCAL  DEFAULT    4
     5: 00000000000003a0     0 SECTION LOCAL  DEFAULT    5
     6: 00000000000003c8     0 SECTION LOCAL  DEFAULT    6
     7: 0000000000000470     0 SECTION LOCAL  DEFAULT    7
     8: 00000000000004f4     0 SECTION LOCAL  DEFAULT    8
     9: 0000000000000508     0 SECTION LOCAL  DEFAULT    9
    10: 0000000000000528     0 SECTION LOCAL  DEFAULT   10
    11: 0000000000000600     0 SECTION LOCAL  DEFAULT   11
    12: 0000000000001000     0 SECTION LOCAL  DEFAULT   12
    13: 0000000000001020     0 SECTION LOCAL  DEFAULT   13
    14: 0000000000001040     0 SECTION LOCAL  DEFAULT   14
    15: 0000000000001050     0 SECTION LOCAL  DEFAULT   15
    16: 0000000000001060     0 SECTION LOCAL  DEFAULT   16
    17: 0000000000001218     0 SECTION LOCAL  DEFAULT   17
    18: 0000000000002000     0 SECTION LOCAL  DEFAULT   18
    19: 000000000000201c     0 SECTION LOCAL  DEFAULT   19
    20: 0000000000002068     0 SECTION LOCAL  DEFAULT   20
    21: 0000000000003db8     0 SECTION LOCAL  DEFAULT   21
    22: 0000000000003dc0     0 SECTION LOCAL  DEFAULT   22
    23: 0000000000003dc8     0 SECTION LOCAL  DEFAULT   23
    24: 0000000000003fb8     0 SECTION LOCAL  DEFAULT   24
    25: 0000000000004000     0 SECTION LOCAL  DEFAULT   25
    26: 0000000000004018     0 SECTION LOCAL  DEFAULT   26
    27: 0000000000000000     0 SECTION LOCAL  DEFAULT   27
    28: 0000000000000000     0 FILE    LOCAL  DEFAULT  ABS crtstuff.c
    29: 0000000000001090     0 FUNC    LOCAL  DEFAULT   16 deregister_tm_clones
    30: 00000000000010c0     0 FUNC    LOCAL  DEFAULT   16 register_tm_clones
    31: 0000000000001100     0 FUNC    LOCAL  DEFAULT   16 __do_global_dtors_aux
    32: 0000000000004018     1 OBJECT  LOCAL  DEFAULT   26 completed.8060
    33: 0000000000003dc0     0 OBJECT  LOCAL  DEFAULT   22 __do_global_dtors_aux_fin
    34: 0000000000001140     0 FUNC    LOCAL  DEFAULT   16 frame_dummy
    35: 0000000000003db8     0 OBJECT  LOCAL  DEFAULT   21 __frame_dummy_init_array_
    36: 0000000000000000     0 FILE    LOCAL  DEFAULT  ABS main.c
    37: 0000000000000000     0 FILE    LOCAL  DEFAULT  ABS crtstuff.c
    38: 000000000000218c     0 OBJECT  LOCAL  DEFAULT   20 __FRAME_END__
    39: 0000000000000000     0 FILE    LOCAL  DEFAULT  ABS
    40: 0000000000003dc0     0 NOTYPE  LOCAL  DEFAULT   21 __init_array_end
    41: 0000000000003dc8     0 OBJECT  LOCAL  DEFAULT   23 _DYNAMIC
    42: 0000000000003db8     0 NOTYPE  LOCAL  DEFAULT   21 __init_array_start
    43: 000000000000201c     0 NOTYPE  LOCAL  DEFAULT   19 __GNU_EH_FRAME_HDR
    44: 0000000000003fb8     0 OBJECT  LOCAL  DEFAULT   24 _GLOBAL_OFFSET_TABLE_
    45: 0000000000001000     0 FUNC    LOCAL  DEFAULT   12 _init
    46: 0000000000001210     5 FUNC    GLOBAL DEFAULT   16 __libc_csu_fini
    47: 0000000000004010     8 OBJECT  GLOBAL DEFAULT   25 my_name
    48: 0000000000000000     0 NOTYPE  WEAK   DEFAULT  UND _ITM_deregisterTMCloneTab
    49: 0000000000004000     0 NOTYPE  WEAK   DEFAULT   25 data_start
    50: 0000000000004018     0 NOTYPE  GLOBAL DEFAULT   25 _edata
    51: 0000000000001218     0 FUNC    GLOBAL HIDDEN    17 _fini
    52: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND printf@@GLIBC_2.2.5
    53: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND __libc_start_main@@GLIBC_
    54: 0000000000004000     0 NOTYPE  GLOBAL DEFAULT   25 __data_start
    55: 0000000000000000     0 NOTYPE  WEAK   DEFAULT  UND __gmon_start__
    56: 0000000000004008     0 OBJECT  GLOBAL HIDDEN    25 __dso_handle
    57: 0000000000002000     4 OBJECT  GLOBAL DEFAULT   18 _IO_stdin_used
    58: 00000000000011a0   101 FUNC    GLOBAL DEFAULT   16 __libc_csu_init
    59: 0000000000004020     0 NOTYPE  GLOBAL DEFAULT   26 _end
    60: 0000000000001060    47 FUNC    GLOBAL DEFAULT   16 _start
    61: 0000000000004018     0 NOTYPE  GLOBAL DEFAULT   26 __bss_start
    62: 0000000000001174    30 FUNC    GLOBAL DEFAULT   16 main
    63: 0000000000001149    43 FUNC    GLOBAL DEFAULT   16 say_hello
    64: 0000000000004018     0 OBJECT  GLOBAL HIDDEN    25 __TMC_END__
    65: 0000000000000000     0 NOTYPE  WEAK   DEFAULT  UND _ITM_registerTMCloneTable
    66: 0000000000000000     0 FUNC    WEAK   DEFAULT  UND __cxa_finalize@@GLIBC_2.2
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br><span class="line-number">31</span><br><span class="line-number">32</span><br><span class="line-number">33</span><br><span class="line-number">34</span><br><span class="line-number">35</span><br><span class="line-number">36</span><br><span class="line-number">37</span><br><span class="line-number">38</span><br><span class="line-number">39</span><br><span class="line-number">40</span><br><span class="line-number">41</span><br><span class="line-number">42</span><br><span class="line-number">43</span><br><span class="line-number">44</span><br><span class="line-number">45</span><br><span class="line-number">46</span><br><span class="line-number">47</span><br><span class="line-number">48</span><br><span class="line-number">49</span><br><span class="line-number">50</span><br><span class="line-number">51</span><br><span class="line-number">52</span><br><span class="line-number">53</span><br><span class="line-number">54</span><br><span class="line-number">55</span><br><span class="line-number">56</span><br><span class="line-number">57</span><br><span class="line-number">58</span><br><span class="line-number">59</span><br><span class="line-number">60</span><br><span class="line-number">61</span><br><span class="line-number">62</span><br><span class="line-number">63</span><br><span class="line-number">64</span><br><span class="line-number">65</span><br><span class="line-number">66</span><br><span class="line-number">67</span><br><span class="line-number">68</span><br><span class="line-number">69</span><br><span class="line-number">70</span><br><span class="line-number">71</span><br><span class="line-number">72</span><br><span class="line-number">73</span><br><span class="line-number">74</span><br><span class="line-number">75</span><br><span class="line-number">76</span><br><span class="line-number">77</span><br><span class="line-number">78</span><br><span class="line-number">79</span><br><span class="line-number">80</span><br><span class="line-number">81</span><br></div></div><p>在最后位置找到了亲切的老朋友 <code>main</code>和<code>say_hello</code></p> <div class="language- line-numbers-mode"><pre class="language-text"><code>    62: 0000000000001174    30 FUNC    GLOBAL DEFAULT   16 main
    63: 0000000000001149    43 FUNC    GLOBAL DEFAULT   16 say_hello
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p><code>main</code>函数符号对应的数值为<code>0x1174</code>，其类型为<code>FUNC</code>，大小为30字节，对应的代码区索引为16。
<code>say_hello</code>函数符号对应数值为<code>0x1149</code>，其类型为<code>FUNC</code>，大小为43字节，对应的代码区索引同为16。
Section Header Table:</p> <div class="language- line-numbers-mode"><pre class="language-text"><code>  [16] .text             PROGBITS         0000000000001060  00001060
       00000000000001b5  0000000000000000  AX       0     0     16
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><h3 id="反汇编代码区">反汇编代码区</h3> <p>在理解了<code>String Table</code>和<code>Symbol Table</code>的作用后，通过<code>objdump</code>反汇编来理解一下<code>.text</code>代码区:</p> <div class="language- line-numbers-mode"><pre class="language-text"><code>root@5e3abe332c5a:/home/docker/case_code_100# objdump -j .text -l -C -S app

0000000000001149 &lt;say_hello&gt;:
say_hello():
    1149:       f3 0f 1e fa             endbr64
    114d:       55                      push   %rbp
    114e:       48 89 e5                mov    %rsp，%rbp
    1151:       48 83 ec 10             sub    $0x10，%rsp
    1155:       48 89 7d f8             mov    %rdi，-0x8(%rbp)
    1159:       48 8b 45 f8             mov    -0x8(%rbp)，%rax
    115d:       48 89 c6                mov    %rax，%rsi
    1160:       48 8d 3d 9d 0e 00 00    lea    0xe9d(%rip)，%rdi        # 2004 &lt;_IO_stdin_used+0x4&gt;
    1167:       b8 00 00 00 00          mov    $0x0，%eax
    116c:       e8 df fe ff ff          callq  1050 &lt;printf@plt&gt;
    1171:       90                      nop
    1172:       c9                      leaveq
    1173:       c3                      retq

0000000000001174 &lt;main&gt;:
main():
    1174:       f3 0f 1e fa             endbr64
    1178:       55                      push   %rbp
    1179:       48 89 e5                mov    %rsp，%rbp
    117c:       48 8b 05 8d 2e 00 00    mov    0x2e8d(%rip)，%rax        # 4010 &lt;my_name&gt;
    1183:       48 89 c7                mov    %rax，%rdi
    1186:       e8 be ff ff ff          callq  1149 &lt;say_hello&gt;
    118b:       b8 00 00 00 00          mov    $0x0，%eax
    1190:       5d                      pop    %rbp
    1191:       c3                      retq
    1192:       66 2e 0f 1f 84 00 00    nopw   %cs:0x0(%rax，%rax，1)
    1199:       00 00 00
    119c:       0f 1f 40 00             nopl   0x0(%rax)
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br><span class="line-number">31</span><br><span class="line-number">32</span><br></div></div><p><code>0x1149</code> <code>0x1174</code>正是<code>say_hello</code>，<code>main</code>函数的入口地址。并看到了激动人心的指令</p> <div class="language- line-numbers-mode"><pre class="language-text"><code>1186:       e8 be ff ff ff          callq  1149 &lt;say_hello&gt;
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><p>很佩服你还能看到这里，牛逼，牛逼! 看了这么久还记得开头的C代码的样子吗？ 再看一遍 : )</p> <div class="language-c line-numbers-mode"><pre class="language-c"><code><span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">include</span> <span class="token string">&lt;stdio.h&gt;</span></span>
<span class="token keyword">void</span> <span class="token function">say_hello</span><span class="token punctuation">(</span><span class="token keyword">char</span> <span class="token operator">*</span>who<span class="token punctuation">)</span>
<span class="token punctuation">{</span>
    <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">&quot;hello， %s!\n&quot;</span>， who<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
<span class="token keyword">char</span> <span class="token operator">*</span>my_name <span class="token operator">=</span> <span class="token string">&quot;harmony os&quot;</span><span class="token punctuation">;</span>
<span class="token keyword">int</span> <span class="token function">main</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
<span class="token punctuation">{</span>
    <span class="token function">say_hello</span><span class="token punctuation">(</span>my_name<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">return</span> <span class="token number">0</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
root@<span class="token number">5e3</span>abe332c5a<span class="token operator">:</span><span class="token operator">/</span>home<span class="token operator">/</span>docker<span class="token operator">/</span>case_code_100# <span class="token punctuation">.</span><span class="token operator">/</span>app
hello， harmony os<span class="token operator">!</span>    
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br></div></div><p>但是!!! 晕，怎么还有but，西卡西...，上面请大家记住的还有一个地方没说到</p> <div class="language- line-numbers-mode"><pre class="language-text"><code>Entry point address:               0x1060   //代码区 .text 起始位置，即程序运行开始位置
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><p>它的地址并不是main函数位置<code>0x1174</code>，是<code>0x1060</code>!而且代码区的开始位置是<code>0x1060</code>没错的。</p> <div class="language- line-numbers-mode"><pre class="language-text"><code>  [16] .text             PROGBITS         0000000000001060  00001060
       00000000000001b5  0000000000000000  AX       0     0     16
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>难度<code>main</code>不是入口地址？ 那<code>0x1060</code>上放的是何方神圣，再查符号表发现是</p> <div class="language- line-numbers-mode"><pre class="language-text"><code>    60: 0000000000001060    47 FUNC    GLOBAL DEFAULT   16 _start
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><p>从反汇编堆中找到 <code>_start</code></p> <div class="language- line-numbers-mode"><pre class="language-text"><code>0000000000001060 &lt;_start&gt;:
_start():
    1060:       f3 0f 1e fa             endbr64
    1064:       31 ed                   xor    %ebp，%ebp
    1066:       49 89 d1                mov    %rdx，%r9
    1069:       5e                      pop    %rsi
    106a:       48 89 e2                mov    %rsp，%rdx
    106d:       48 83 e4 f0             and    $0xfffffffffffffff0，%rsp
    1071:       50                      push   %rax
    1072:       54                      push   %rsp
    1073:       4c 8d 05 96 01 00 00    lea    0x196(%rip)，%r8        # 1210 &lt;__libc_csu_fini&gt;
    107a:       48 8d 0d 1f 01 00 00    lea    0x11f(%rip)，%rcx        # 11a0 &lt;__libc_csu_init&gt;
    1081:       48 8d 3d ec 00 00 00    lea    0xec(%rip)，%rdi        # 1174 &lt;main&gt;
    1088:       ff 15 52 2f 00 00       callq  *0x2f52(%rip)        # 3fe0 &lt;__libc_start_main@GLIBC_2.2.5&gt;
    108e:       f4                      hlt
    108f:       90                      nop
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br></div></div><p>这才看到了<code>0x1174</code>的<code>main</code>函数。所以真正的说法是:</p> <ul><li>从内核动态加载的视角看，程序运行首个函数并不是<code>main</code>，而是<code>_start</code>。</li> <li>但从应用程序开发者视角看，<code>main</code>就是启动函数。</li></ul> <h3 id="百文说内核-抓住主脉络">百文说内核 | 抓住主脉络</h3> <ul><li>百文相当于摸出内核的肌肉和器官系统，让人开始丰满有立体感，因是直接从注释源码起步，在加注释过程中，每每有心得处就整理,慢慢形成了以下文章。内容立足源码，常以生活场景打比方尽可能多的将内核知识点置入某种场景，具有画面感，容易理解记忆。说别人能听得懂的话很重要! 百篇博客绝不是百度教条式的在说一堆诘屈聱牙的概念，那没什么意思。更希望让内核变得栩栩如生，倍感亲切。</li> <li>与代码需不断<code>debug</code>一样，文章内容会存在不少错漏之处，请多包涵，但会反复修正，持续更新，<code>v**.xx</code> 代表文章序号和修改的次数，精雕细琢，言简意赅，力求打造精品内容。</li> <li>百文在 &lt; 鸿蒙研究站 | 开源中国 | 博客园 | 51cto | csdn | 知乎 | 掘金 &gt; 站点发布，百篇博客系列目录如下。</li> <li><img src="https://weharmonyos.oss-cn-hangzhou.aliyuncs.com/resources/common/cate.png" alt=""></li></ul> <p>按功能模块:</p> <table><thead><tr><th style="text-align:center;">基础知识</th> <th style="text-align:center;">进程管理</th> <th style="text-align:center;">任务管理</th> <th style="text-align:center;">内存管理</th></tr></thead> <tbody><tr><td style="text-align:center;"><a href="http://weharmonyos.com/blog/01.html" target="_blank" rel="noopener noreferrer">双向链表</a><br><a href="http://weharmonyos.com/blog/02.html" target="_blank" rel="noopener noreferrer">内核概念</a><br><a href="http://weharmonyos.com/blog/03.html" target="_blank" rel="noopener noreferrer">源码结构</a><br><a href="http://weharmonyos.com/blog/04.html" target="_blank" rel="noopener noreferrer">地址空间</a><br><a href="http://weharmonyos.com/blog/05.html" target="_blank" rel="noopener noreferrer">计时单位</a><br><a href="http://weharmonyos.com/blog/06.html" target="_blank" rel="noopener noreferrer">优雅的宏</a><br><a href="http://weharmonyos.com/blog/07.html" target="_blank" rel="noopener noreferrer">钩子框架</a><br><a href="http://weharmonyos.com/blog/08.html" target="_blank" rel="noopener noreferrer">位图管理</a><br><a href="http://weharmonyos.com/blog/09.html" target="_blank" rel="noopener noreferrer">POSIX</a><br><a href="http://weharmonyos.com/blog/10.html" target="_blank" rel="noopener noreferrer">main函数</a><br></td> <td style="text-align:center;"><a href="http://weharmonyos.com/blog/11.html" target="_blank" rel="noopener noreferrer">调度故事</a><br><a href="http://weharmonyos.com/blog/12.html" target="_blank" rel="noopener noreferrer">进程控制块</a><br><a href="http://weharmonyos.com/blog/13.html" target="_blank" rel="noopener noreferrer">进程空间</a><br><a href="http://weharmonyos.com/blog/14.html" target="_blank" rel="noopener noreferrer">线性区</a><br><a href="http://weharmonyos.com/blog/15.html" target="_blank" rel="noopener noreferrer">红黑树</a><br><a href="http://weharmonyos.com/blog/16.html" target="_blank" rel="noopener noreferrer">进程管理</a><br><a href="http://weharmonyos.com/blog/17.html" target="_blank" rel="noopener noreferrer">Fork进程</a><br><a href="http://weharmonyos.com/blog/18.html" target="_blank" rel="noopener noreferrer">进程回收</a><br><a href="http://weharmonyos.com/blog/19.html" target="_blank" rel="noopener noreferrer">Shell编辑</a><br><a href="http://weharmonyos.com/blog/20.html" target="_blank" rel="noopener noreferrer">Shell解析</a><br></td> <td style="text-align:center;"><a href="http://weharmonyos.com/blog/21.html" target="_blank" rel="noopener noreferrer">任务控制块</a><br><a href="http://weharmonyos.com/blog/22.html" target="_blank" rel="noopener noreferrer">并发并行</a><br><a href="http://weharmonyos.com/blog/23.html" target="_blank" rel="noopener noreferrer">就绪队列</a><br><a href="http://weharmonyos.com/blog/24.html" target="_blank" rel="noopener noreferrer">调度机制</a><br><a href="http://weharmonyos.com/blog/25.html" target="_blank" rel="noopener noreferrer">任务管理</a><br><a href="http://weharmonyos.com/blog/26.html" target="_blank" rel="noopener noreferrer">用栈方式</a><br><a href="http://weharmonyos.com/blog/27.html" target="_blank" rel="noopener noreferrer">软件定时器</a><br><a href="http://weharmonyos.com/blog/28.html" target="_blank" rel="noopener noreferrer">控制台</a><br><a href="http://weharmonyos.com/blog/29.html" target="_blank" rel="noopener noreferrer">远程登录</a><br><a href="http://weharmonyos.com/blog/30.html" target="_blank" rel="noopener noreferrer">协议栈</a><br></td> <td style="text-align:center;"><a href="http://weharmonyos.com/blog/31.html" target="_blank" rel="noopener noreferrer">内存规则</a><br><a href="http://weharmonyos.com/blog/32.html" target="_blank" rel="noopener noreferrer">物理内存</a><br><a href="http://weharmonyos.com/blog/33.html" target="_blank" rel="noopener noreferrer">内存概念</a><br><a href="http://weharmonyos.com/blog/34.html" target="_blank" rel="noopener noreferrer">虚实映射</a><br><a href="http://weharmonyos.com/blog/35.html" target="_blank" rel="noopener noreferrer">页表管理</a><br><a href="http://weharmonyos.com/blog/36.html" target="_blank" rel="noopener noreferrer">静态分配</a><br><a href="http://weharmonyos.com/blog/37.html" target="_blank" rel="noopener noreferrer">TLFS算法</a><br><a href="http://weharmonyos.com/blog/38.html" target="_blank" rel="noopener noreferrer">内存池管理</a><br><a href="http://weharmonyos.com/blog/39.html" target="_blank" rel="noopener noreferrer">原子操作</a><br><a href="http://weharmonyos.com/blog/40.html" target="_blank" rel="noopener noreferrer">圆整对齐</a><br></td></tr> <tr><td style="text-align:center;">通讯机制</td> <td style="text-align:center;">文件系统</td> <td style="text-align:center;">硬件架构</td> <td style="text-align:center;">内核汇编</td></tr> <tr><td style="text-align:center;"><a href="http://weharmonyos.com/blog/41.html" target="_blank" rel="noopener noreferrer">通讯总览</a><br><a href="http://weharmonyos.com/blog/42.html" target="_blank" rel="noopener noreferrer">自旋锁</a><br><a href="http://weharmonyos.com/blog/43.html" target="_blank" rel="noopener noreferrer">互斥锁</a><br><a href="http://weharmonyos.com/blog/44.html" target="_blank" rel="noopener noreferrer">快锁使用</a><br><a href="http://weharmonyos.com/blog/45.html" target="_blank" rel="noopener noreferrer">快锁实现</a><br><a href="http://weharmonyos.com/blog/46.html" target="_blank" rel="noopener noreferrer">读写锁</a><br><a href="http://weharmonyos.com/blog/47.html" target="_blank" rel="noopener noreferrer">信号量</a><br><a href="http://weharmonyos.com/blog/48.html" target="_blank" rel="noopener noreferrer">事件机制</a><br><a href="http://weharmonyos.com/blog/49.html" target="_blank" rel="noopener noreferrer">信号生产</a><br><a href="http://weharmonyos.com/blog/50.html" target="_blank" rel="noopener noreferrer">信号消费</a><br><a href="http://weharmonyos.com/blog/51.html" target="_blank" rel="noopener noreferrer">消息队列</a><br><a href="http://weharmonyos.com/blog/52.html" target="_blank" rel="noopener noreferrer">消息封装</a><br><a href="http://weharmonyos.com/blog/53.html" target="_blank" rel="noopener noreferrer">消息映射</a><br><a href="http://weharmonyos.com/blog/54.html" target="_blank" rel="noopener noreferrer">共享内存</a><br></td> <td style="text-align:center;"><a href="http://weharmonyos.com/blog/55.html" target="_blank" rel="noopener noreferrer">文件概念</a><br><a href="http://weharmonyos.com/blog/56.html" target="_blank" rel="noopener noreferrer">文件故事</a><br><a href="http://weharmonyos.com/blog/57.html" target="_blank" rel="noopener noreferrer">索引节点</a><br><a href="http://weharmonyos.com/blog/58.html" target="_blank" rel="noopener noreferrer">VFS</a><br><a href="http://weharmonyos.com/blog/59.html" target="_blank" rel="noopener noreferrer">文件句柄</a><br><a href="http://weharmonyos.com/blog/60.html" target="_blank" rel="noopener noreferrer">根文件系统</a><br><a href="http://weharmonyos.com/blog/61.html" target="_blank" rel="noopener noreferrer">挂载机制</a><br><a href="http://weharmonyos.com/blog/62.html" target="_blank" rel="noopener noreferrer">管道文件</a><br><a href="http://weharmonyos.com/blog/63.html" target="_blank" rel="noopener noreferrer">文件映射</a><br><a href="http://weharmonyos.com/blog/64.html" target="_blank" rel="noopener noreferrer">写时拷贝</a><br></td> <td style="text-align:center;"><a href="http://weharmonyos.com/blog/65.html" target="_blank" rel="noopener noreferrer">芯片模式</a><br><a href="http://weharmonyos.com/blog/66.html" target="_blank" rel="noopener noreferrer">ARM架构</a><br><a href="http://weharmonyos.com/blog/67.html" target="_blank" rel="noopener noreferrer">指令集</a><br><a href="http://weharmonyos.com/blog/68.html" target="_blank" rel="noopener noreferrer">协处理器</a><br><a href="http://weharmonyos.com/blog/69.html" target="_blank" rel="noopener noreferrer">工作模式</a><br><a href="http://weharmonyos.com/blog/70.html" target="_blank" rel="noopener noreferrer">寄存器</a><br><a href="http://weharmonyos.com/blog/71.html" target="_blank" rel="noopener noreferrer">多核管理</a><br><a href="http://weharmonyos.com/blog/72.html" target="_blank" rel="noopener noreferrer">中断概念</a><br><a href="http://weharmonyos.com/blog/73.html" target="_blank" rel="noopener noreferrer">中断管理</a><br></td> <td style="text-align:center;"><a href="http://weharmonyos.com/blog/74.html" target="_blank" rel="noopener noreferrer">编码方式</a><br><a href="http://weharmonyos.com/blog/75.html" target="_blank" rel="noopener noreferrer">汇编基础</a><br><a href="http://weharmonyos.com/blog/76.html" target="_blank" rel="noopener noreferrer">汇编传参</a><br><a href="http://weharmonyos.com/blog/77.html" target="_blank" rel="noopener noreferrer">链接脚本</a><br><a href="http://weharmonyos.com/blog/78.html" target="_blank" rel="noopener noreferrer">内核启动</a><br><a href="http://weharmonyos.com/blog/79.html" target="_blank" rel="noopener noreferrer">进程切换</a><br><a href="http://weharmonyos.com/blog/80.html" target="_blank" rel="noopener noreferrer">任务切换</a><br><a href="http://weharmonyos.com/blog/81.html" target="_blank" rel="noopener noreferrer">中断切换</a><br><a href="http://weharmonyos.com/blog/82.html" target="_blank" rel="noopener noreferrer">异常接管</a><br><a href="http://weharmonyos.com/blog/83.html" target="_blank" rel="noopener noreferrer">缺页中断</a><br></td></tr> <tr><td style="text-align:center;">编译运行</td> <td style="text-align:center;">调测工具</td> <td style="text-align:center;"></td> <td style="text-align:center;"></td></tr> <tr><td style="text-align:center;"><a href="http://weharmonyos.com/blog/84.html" target="_blank" rel="noopener noreferrer">编译过程</a><br><a href="http://weharmonyos.com/blog/85.html" target="_blank" rel="noopener noreferrer">编译构建</a><br><a href="http://weharmonyos.com/blog/86.html" target="_blank" rel="noopener noreferrer">GN语法</a><br><a href="http://weharmonyos.com/blog/87.html" target="_blank" rel="noopener noreferrer">忍者无敌</a><br><a href="http://weharmonyos.com/blog/88.html" target="_blank" rel="noopener noreferrer">ELF格式</a><br><a href="http://weharmonyos.com/blog/89.html" target="_blank" rel="noopener noreferrer">ELF解析</a><br><a href="http://weharmonyos.com/blog/90.html" target="_blank" rel="noopener noreferrer">静态链接</a><br><a href="http://weharmonyos.com/blog/91.html" target="_blank" rel="noopener noreferrer">重定位</a><br><a href="http://weharmonyos.com/blog/92.html" target="_blank" rel="noopener noreferrer">动态链接</a><br><a href="http://weharmonyos.com/blog/93.html" target="_blank" rel="noopener noreferrer">进程映像</a><br><a href="http://weharmonyos.com/blog/94.html" target="_blank" rel="noopener noreferrer">应用启动</a><br><a href="http://weharmonyos.com/blog/95.html" target="_blank" rel="noopener noreferrer">系统调用</a><br><a href="http://weharmonyos.com/blog/96.html" target="_blank" rel="noopener noreferrer">VDSO</a><br></td> <td style="text-align:center;"><a href="http://weharmonyos.com/blog/97.html" target="_blank" rel="noopener noreferrer">模块监控</a><br><a href="http://weharmonyos.com/blog/98.html" target="_blank" rel="noopener noreferrer">日志跟踪</a><br><a href="http://weharmonyos.com/blog/99.html" target="_blank" rel="noopener noreferrer">系统安全</a><br><a href="http://weharmonyos.com/blog/100.html" target="_blank" rel="noopener noreferrer">测试用例</a><br></td> <td style="text-align:center;"></td> <td style="text-align:center;"></td></tr></tbody></table> <h3 id="百万注源码-处处扣细节">百万注源码 | 处处扣细节</h3> <ul><li><p>百万汉字注解内核目的是要看清楚其毛细血管，细胞结构，等于在拿放大镜看内核。内核并不神秘，带着问题去源码中找答案是很容易上瘾的，你会发现很多文章对一些问题的解读是错误的，或者说不深刻难以自圆其说，你会慢慢形成自己新的解读，而新的解读又会碰到新的问题，如此层层递进，滚滚向前，拿着放大镜根本不愿意放手。</p></li> <li><p><a href="https://gitee.com/weharmony/kernel_liteos_a_note" target="_blank" rel="noopener noreferrer">&lt; gitee</a> | <a href="https://github.com/kuangyufei/kernel_liteos_a_note" target="_blank" rel="noopener noreferrer">github</a> | <a href="https://weharmony.coding.net/public/harmony/kernel_liteos_a_note/git/files" target="_blank" rel="noopener noreferrer">coding</a> | <a href="https://gitcode.net/kuangyufei/kernel_liteos_a_note" target="_blank" rel="noopener noreferrer">gitcode &gt;</a> 四大码仓推送 | 同步官方源码。</p> <p><a href="https://gitee.com/weharmony/kernel_liteos_a_note" target="_blank" rel="noopener noreferrer"><img src="https://gitee.com/weharmony/kernel_liteos_a_note/widgets/widget_card.svg?colors=393222,ebdfc1,fffae5,d8ca9f,393222,a28b40" alt=""></a></p></li></ul> <h3 id="关注不迷路-代码即人生">关注不迷路 | 代码即人生</h3> <p><img src="https://weharmonyos.oss-cn-hangzhou.aliyuncs.com/resources/common/so1so.png" alt=""></p> <ul><li>互联网从业十五年，计算机硕士，技术副总裁</li> <li>关注我，持续更新四十年，即聊技术也聊人生</li> <li>交有趣靠谱的人；做难而正确的事</li> <li>不做作，不炒作，只唯真</li> <li>不唯上，不唯书，只唯实</li></ul> <p><a href="http://weharmonyos.com/donate.html" target="_blank" rel="noopener noreferrer"> &gt;&gt; 捐助名单</a></p> <p>据说喜欢 <strong>点赞 + 分享</strong> 的,后来都成了大神。😃</p></div> <!----> <div class="content__content-bottom"></div> <footer class="page-meta"><!----> <!----> <!----></footer> <div class="page-nav"><p class="inner"><span class="prev"><a href="/blog/87.html" class="prev"><svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" class="icon prev-icon"><path d="M906.783 588.79c-.02 8.499-6.882 15.36-15.38 15.37l-443.7-.01 75.704 191.682c2.52 6.42.482 13.763-5.038 17.91-5.52 4.168-13.138 4.147-18.616-.092L123.228 524.175a15.362 15.362 0 0 1-6-12.165c0-4.782 2.222-9.277 6-12.185L499.753 210.35a15.388 15.388 0 0 1 9.38-3.195c3.236 0 6.502 1.034 9.236 3.103 5.52 4.147 7.578 11.49 5.038 17.91L447.683 419.84l443.72-.01c8.498.01 15.36 6.881 15.36 15.36l.02 153.6z" fill="currentColor"></path></svg>
        忍者无敌
      </a></span> <span class="next"><a href="/blog/89.html">
        ELF解析
        <svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" class="icon next-icon"><path d="M906.772 512c0 4.772-2.211 9.267-5.99 12.175L524.257 813.66a15.37 15.37 0 0 1-18.616.092 15.368 15.368 0 0 1-5.038-17.91l75.714-191.672h-443.73c-8.488 0-15.36-6.881-15.36-15.36v-153.6c0-8.489 6.872-15.36 15.36-15.36h443.73l-75.714-191.682a15.358 15.358 0 0 1 5.048-17.91c5.51-4.158 13.128-4.137 18.606.092l376.525 289.485a15.323 15.323 0 0 1 5.99 12.165z" fill="currentColor"></path></svg></a></span></p></div> <!----> <!----> <div class="content__page-bottom"></div></main> <!----></div><div class="global-ui"><!----><!----><div id="pwa-install"><!----> <div id="install-modal-wrapper" style="display:none;"><div class="background"></div> <div class="install-modal"><div class="header"><button aria-label="Close" class="close-button"><svg width="23" height="22" xmlns="http://www.w3.org/2000/svg" class="icon close-icon"><path fill-rule="evenodd" clip-rule="evenodd" d="M1.12.358a1.224 1.224 0 011.729 0l8.92 8.914L20.686.358a1.224 1.224 0 011.73 1.728L13.497 11l8.92 8.913a1.222 1.222 0 11-1.73 1.729l-8.919-8.913-8.92 8.913a1.224 1.224 0 01-1.729-1.729L10.04 11l-8.92-8.914a1.222 1.222 0 010-1.728z" fill="currentColor"></path></svg></button> <div class="logo"><!----> <div class="title"><h1></h1> <p class="desc">This app can be installed on your PC or mobile device.  This will allow this web app to look and behave like any other installed app.  You will find it in your app lists and be able to pin it to your home screen, start menus or task bars.  This installed web app will also be able to safely interact with other apps and your operating system. </p></div></div></div> <div class="content"><div class="highlight"><!----> <!----></div> <div class="description"><h3>Description</h3> <p></p></div></div> <div class="button-wrapper"><button class="install-button">
        Install <span></span></button> <button class="cancel-button">
        Cancel
      </button></div></div></div></div><div tabindex="-1" role="dialog" aria-hidden="true" class="pswp"><div class="pswp__bg"></div> <div class="pswp__scroll-wrap"><div class="pswp__container"><div class="pswp__item"></div> <div class="pswp__item"></div> <div class="pswp__item"></div></div> <div class="pswp__ui pswp__ui--hidden"><div class="pswp__top-bar"><div class="pswp__counter"></div> <button title="Close" aria-label="Close" class="pswp__button pswp__button--close"></button> <button title="Share" aria-label="Share" class="pswp__button pswp__button--share"></button> <button title="Switch to full screen" aria-label="Switch to full screen" class="pswp__button pswp__button--fs"></button> <button title="Zoom in/out" aria-label="Zoom in/out" class="pswp__button pswp__button--zoom"></button> <div class="pswp__preloader"><div class="pswp__preloader__icn"><div class="pswp__preloader__cut"><div class="pswp__preloader__donut"></div></div></div></div></div> <div class="pswp__share-modal pswp__share-modal--hidden pswp__single-tap"><div class="pswp__share-tooltip"></div></div> <button title="Prev (Arrow Left)" aria-label="Prev (Arrow Left)" class="pswp__button pswp__button--arrow--left"></button> <button title="Next (Arrow Right)" aria-label="Next (Arrow Right)" class="pswp__button pswp__button--arrow--right"></button> <div class="pswp__caption"><div class="pswp__caption__center"></div></div></div></div></div></div></div>
    <script src="/assets/js/app.9a8b95d8.js" defer></script><script src="/assets/js/vendors~layout-Layout.c1e797d4.js" defer></script><script src="/assets/js/vendors~layout-Blog~layout-Layout~layout-NotFound.f75cf258.js" defer></script><script src="/assets/js/page--70e38af0.eb8ffc53.js" defer></script>
  </body>
</html>
